libev port of ShadowsocksR
C Makefile Shell Groff Assembly M4 Other
Pull request Compare This branch is 222 commits ahead, 230 commits behind shadowsocksr:master.
Latest commit 6fa8717 Jan 19, 2017 @breakwa11 breakwa11 committed with esdeathlove fix host name setting
Failed to load latest commit information.
.github Add issue template Sep 24, 2016
acl Update ACL Dec 30, 2016
auto Add HTTP/SNI parser (#809) Sep 24, 2016
completions/bash fix -l completion Dec 10, 2016
debian package bash completion files Dec 10, 2016
doc add `user` config option Dec 10, 2016
docker Bump version Nov 11, 2016
libcork Fix #993 Dec 10, 2016
libev Enable kqueue for freebsd again Oct 18, 2016
libipset Refine libpcre searching Sep 24, 2016
libsodium Update ax_pthread Dec 20, 2015
libudns Refine libpcre searching Sep 24, 2016
m4 Fix mingw building Sep 24, 2016
rpm fix broken EL6 packaging support Dec 10, 2016
src fix host name setting Jan 20, 2017
.gitignore Ignore generated spec Nov 11, 2016
.travis.yml Fix dependency issue Jul 4, 2016
.uncrustify.cfg Clean up Sep 24, 2016
AUTHORS add AUTHORS Jun 17, 2016
COPYING add debian package description Apr 6, 2013
Changes Bump version Nov 11, 2016
INSTALL fix autoconf Jan 6, 2013
LICENSE Update LICENSE Nov 14, 2013 fix disable-documentation option (#700) Jul 4, 2016 Refine libpcre searching Sep 24, 2016 Bump version Nov 11, 2016
aclocal.m4 Refine libpcre searching Sep 24, 2016 bump version Apr 5, 2013 Refine libpcre searching Sep 24, 2016
configure Bump version Nov 11, 2016 check for libsodium, libev, libudns if configured with system library Dec 10, 2016
more Refine the ACL behavior Nov 11, 2016 Rename libshadowsocks to libshadowsocks-libev Jun 1, 2016
tail Refine the ACL behavior Nov 11, 2016



Shadowsocks-libev is a lightweight secured SOCKS5 proxy for embedded devices and low-end boxes.

It is a port of Shadowsocks created by @clowwindy, which is maintained by @madeye and @linusyang.

Current version: 2.5.6 | Changelog

Travis CI: Travis CI


Shadowsocks-libev is written in pure C and only depends on libev and OpenSSL or mbedTLS or PolarSSL.

In normal usage, the memory footprint is about 600KB and the CPU utilization is no more than 5% on a low-end router (Buffalo WHR-G300N V2 with a 400MHz MIPS CPU, 32MB memory and 4MB flash).

For a full list of feature comparison between different versions of shadowsocks, refer to the Wiki page.


Distribution-specific guide

Pre-build configure guide

For a complete list of avaliable configure-time option, try configure --help.

Using alternative crypto library

There are three crypto libraries available:

  • OpenSSL (default)
  • mbedTLS
  • PolarSSL (Deprecated)

To build against mbedTLS, specify --with-crypto-library=mbedtls and --with-mbedtls=/path/to/mbedtls when running ./configure.

Windows users will need extra work when compiling mbedTLS library, see this issue for detail info.

PolarSSL (Deprecated)

To build against PolarSSL, specify --with-crypto-library=polarssl and --with-polarssl=/path/to/polarssl when running ./configure.

  • PolarSSL 1.2.5 or newer is required. Currently, PolarSSL does NOT support CAST5-CFB, DES-CFB, IDEA-CFB, RC2-CFB and SEED-CFB.
  • RC4 is only support by PolarSSL 1.3.0 or above.

Using shared library from system

Please specify --enable-system-shared-lib. This will replace the bundled libev, libsodium and libudns with the corresponding libraries installed in the system during compilation and linking.

Debian & Ubuntu

Install from repository

Note: The repositories doesn't always contain the latest version. Please build from source if you want the latest version (see below)

Using official repository for Debian unstable:

sudo apt update
sudo apt install shadowsocks-libev

Build deb package from source

Supported Platforms:

  • Debian 7 (see below), 8, unstable
  • Ubuntu 14.04 (see below), Ubuntu 14.10, 15.04, 15.10 or higher

Note for Ubuntu 14.04 users: Packages built on Ubuntu 14.04 may be used in later Ubuntu versions. However, packages built on Debian 7/8/9 or Ubuntu 14.10+ cannot be installed on Ubuntu 14.04.

Note for Debian 7.x users: To build packages on Debian 7 (Wheezy), you need to enable debian-backports to install systemd-compatibility packages like dh-systemd or init-system-helpers. Please follow the instructions on Debian Backports.

This also means that you can only install those built packages on systems that have init-system-helpers installed.

Otherwise, try to build and install directly from source. See the Linux section below.

cd shadowsocks-libev
sudo apt-get install --no-install-recommends build-essential autoconf libtool libssl-dev \
    gawk debhelper dh-systemd init-system-helpers pkg-config asciidoc xmlto
dpkg-buildpackage -b -us -uc -i
cd ..
sudo dpkg -i shadowsocks-libev*.deb

Configure and start the service

# Edit the configuration file
sudo vim /etc/shadowsocks-libev/config.json

# Edit the default configuration for debian
sudo vim /etc/default/shadowsocks-libev

# Start the service
sudo /etc/init.d/shadowsocks-libev start    # for sysvinit, or
sudo systemctl start shadowsocks-libev      # for systemd

Fedora & RHEL

Supported distributions include

  • Fedora 22, 23, 24
  • RHEL 6, 7 and derivatives (including CentOS, Scientific Linux)

Install from repository

Enable repo via dnf:

su -c 'dnf copr enable librehat/shadowsocks'

Or download yum repo on Fedora Copr and put it inside /etc/yum.repos.d/. The release Epel is for RHEL and its derivatives.

Then, install shadowsocks-libev via dnf:

su -c 'dnf update'
su -c 'dnf install shadowsocks-libev'

or yum:

su -c 'yum update'
su -c 'yum install shadowsocks-libev'


Install from repository

Use the following command to install from repository.

sudo zypper install shadowsocks-libev

Build from source

You should install zlib-devel and libopenssl-devel first.

sudo zypper update
sudo zypper install zlib-devel libopenssl-devel

Then download the source package and compile.

git clone
cd shadowsocks-libev
./configure && make
sudo make install


sudo pacman -S shadowsocks-libev

Please refer to downstream PKGBUILD script for extra modifications and distribution-specific bugs.


nix-env -iA nixos.shadowsocks-libev


nix-env -iA nixpkgs.shadowsocks-libev


For Unix-like systems, especially Debian-based systems, e.g. Ubuntu, Debian or Linux Mint, you can build the binary like this:

# Debian / Ubuntu
sudo apt-get install --no-install-recommends build-essential autoconf libtool libssl-dev libpcre3-dev asciidoc xmlto
# CentOS / Fedora / RHEL
sudo yum install gcc autoconf libtool automake make zlib-devel openssl-devel asciidoc xmlto
./configure && make
sudo make install


cd /usr/ports/net/shadowsocks-libev
make install

Edit your config.json file. By default, it's located in /usr/local/etc/shadowsocks-libev.

To enable shadowsocks-libev, add the following rc variable to your /etc/rc.conf file:


Start the Shadowsocks server:

service shadowsocks_libev start


The OpenWRT project is maintained here: openwrt-shadowsocks.


For OS X, use Homebrew to install or build.

Install Homebrew:

ruby -e "$(curl -fsSL"

Install shadowsocks-libev:

brew install shadowsocks-libev


For Windows, use either MinGW (msys) or Cygwin to build. At the moment, only ss-local is supported to build against MinGW (msys).

If you are using MinGW (msys), please download OpenSSL or PolarSSL source tarball to the home directory of msys, and build it like this (may take a few minutes):


tar zxf openssl-1.0.1e.tar.gz
cd openssl-1.0.1e
./config --prefix="$HOME/prebuilt" --openssldir="$HOME/prebuilt/openssl"
make && make install


tar zxf polarssl-1.3.2-gpl.tgz
cd polarssl-1.3.2
make lib WINDOWS=1
make install DESTDIR="$HOME/prebuilt"

Then, build the binary using the commands below, and all .exe files will be built at $HOME/ss/bin:


./configure --prefix="$HOME/ss" --with-openssl="$HOME/prebuilt"
make && make install


./configure --prefix="$HOME/ss" --with-crypto-library=polarssl --with-polarssl=$HOME/prebuilt
make && make install


For a detailed and complete list of all supported arguments, you may refer to the man pages of the applications, respectively.


       -s <server_host>           host name or ip address of your remote server

       -p <server_port>           port number of your remote server

       -l <local_port>            port number of your local server

       -k <password>              password of your remote server

       [-m <encrypt_method>]      encrypt method: table, rc4, rc4-md5,
                                  aes-128-cfb, aes-192-cfb, aes-256-cfb,
                                  bf-cfb, camellia-128-cfb, camellia-192-cfb,
                                  camellia-256-cfb, cast5-cfb, des-cfb, idea-cfb,
                                  rc2-cfb, seed-cfb, salsa20 ,chacha20 and

       [-f <pid_file>]            the file path to store pid

       [-t <timeout>]             socket timeout in seconds

       [-c <config_file>]         the path to config file

       [-i <interface>]           network interface to bind,
                                  not available in redir mode

       [-b <local_address>]       local address to bind,
                                  not available in server mode

       [-u]                       enable udprelay mode,
                                  TPROXY is required in redir mode

       [-U]                       enable UDP relay and disable TCP relay,
                                  not available in local mode

       [-A]                       enable onetime authentication

       [-L <addr>:<port>]         specify destination server address and port
                                  for local port forwarding,
                                  only available in tunnel mode

       [-d <addr>]                setup name servers for internal DNS resolver,
                                  only available in server mode

       [--fast-open]              enable TCP fast open,
                                  only available in local and server mode,
                                  with Linux kernel > 3.7.0

       [--acl <acl_file>]         config file of ACL (Access Control List)
                                  only available in local and server mode

       [--manager-address <addr>] UNIX domain socket address
                                  only available in server and manager mode

       [--executable <path>]      path to the executable of ss-server
                                  only available in manager mode

       [-v]                       verbose mode


    ss-redir provides a transparent proxy function and only works on the
    Linux platform with iptables.

Advanced usage

The latest shadowsocks-libev has provided a redir mode. You can configure your Linux-based box or router to proxy all TCP traffic transparently.

# Create new chain
root@Wrt:~# iptables -t nat -N SHADOWSOCKS
root@Wrt:~# iptables -t mangle -N SHADOWSOCKS

# Ignore your shadowsocks server's addresses
# It's very IMPORTANT, just be careful.
root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d -j RETURN

# Ignore LANs and any other addresses you'd like to bypass the proxy
# See Wikipedia and RFC5735 for full list of reserved networks.
# See ashi009/bestroutetb for a highly optimized CHN route list.
root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d -j RETURN
root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d -j RETURN
root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d -j RETURN
root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d -j RETURN
root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d -j RETURN
root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d -j RETURN
root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d -j RETURN
root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d -j RETURN

# Anything else should be redirected to shadowsocks's local port
root@Wrt:~# iptables -t nat -A SHADOWSOCKS -p tcp -j REDIRECT --to-ports 12345

# Add any UDP rules
root@Wrt:~# ip route add local default dev lo table 100
root@Wrt:~# ip rule add fwmark 1 lookup 100
root@Wrt:~# iptables -t mangle -A SHADOWSOCKS -p udp --dport 53 -j TPROXY --on-port 12345 --tproxy-mark 0x01/0x01
root@Wrt:~# iptables -t mangle -A SHADOWSOCKS_MARK -p udp --dport 53 -j MARK --set-mark 1

# Apply the rules
root@Wrt:~# iptables -t nat -A OUTPUT -p tcp -j SHADOWSOCKS
root@Wrt:~# iptables -t mangle -A PREROUTING -j SHADOWSOCKS
root@Wrt:~# iptables -t mangle -A OUTPUT -j SHADOWSOCKS_MARK

# Start the shadowsocks-redir
root@Wrt:~# ss-redir -u -c /etc/config/shadowsocks.json -f /var/run/

Shadowsocks over KCP

It's quite easy to use shadowsocks and KCP together with kcptun.

The goal of shadowsocks over KCP is to provide a fully configurable, UDP based protocol to improve poor connections, e.g. a high packet loss 3G network.

Setup your server

server_linux_amd64 -l :21 -t --crypt none --mtu 1200 --nocomp --mode normal --dscp 46 &
ss-server -s -p 443 -k passwd -m chacha20 -u

Setup your client

client_linux_amd64 -l -r <server_ip>:21 --crypt none --mtu 1200 --nocomp --mode normal --dscp 46 &
ss-local -s -p 1090 -k passwd -m chacha20 -l 1080 -b &
ss-local -s <server_ip> -p 443 -k passwd -m chacha20 -l 1080 -U -b

Security Tips

Although shadowsocks-libev can handle thousands of concurrent connections nicely, we still recommend setting up your server's firewall rules to limit connections from each user:

# Up to 32 connections are enough for normal usage
iptables -A INPUT -p tcp --syn --dport ${SHADOWSOCKS_PORT} -m connlimit --connlimit-above 32 -j REJECT --reject-with tcp-reset


Copyright (C) 2016 Max Lv

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see