libev port of ShadowsocksR
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
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.
For a complete list of avaliable configure-time option,
try configure --help.
There are three crypto libraries available:
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.
To build against PolarSSL, specify --with-crypto-library=polarssl
and --with-polarssl=/path/to/polarssl when running ./configure.
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.
Note: The repositories doesn't always contain the latest version. Please build from source if you want the latest version (see below)
Shadowsocks-libev is available in the official repository for Debian 9("Stretch"), unstable, Ubuntu 16.10 and later derivatives:
sudo apt update
sudo apt install shadowsocks-libevFor Debian Jessie users, please install it from jessie-backports:
sudo sh -c 'printf "deb http://ftp.debian.org/debian jessie-backports main" > /etc/apt/sources.list.d/jessie-backports.list'
sudo apt update
sudo apt -t jessie-backports install shadowsocks-libevSupported Platforms:
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 apg libpcre3-dev
dpkg-buildpackage -b -us -uc -i
cd ..
sudo dpkg -i shadowsocks-libev*.deb# 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 systemdSupported distributions include
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'Use the following command to install from repository.
sudo zypper install shadowsocks-libevYou should install zlib-devel and libopenssl-devel first.
sudo zypper update
sudo zypper install zlib-devel libopenssl-develThen download the source package and compile.
git clone https://github.com/shadowsocks/shadowsocks-libev.git
cd shadowsocks-libev
./configure && make
sudo make installsudo pacman -S shadowsocks-libevPlease refer to downstream PKGBUILD script for extra modifications and distribution-specific bugs.
nix-env -iA nixos.shadowsocks-libevnix-env -iA nixpkgs.shadowsocks-libevFor 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 installsu
cd /usr/ports/net/shadowsocks-libev
make installEdit 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:
shadowsocks_libev_enable="YES"Start the Shadowsocks server:
service shadowsocks_libev startThe OpenWRT project is maintained here: openwrt-shadowsocks.
For OS X, use Homebrew to install or build.
Install Homebrew:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"Install shadowsocks-libev:
brew install shadowsocks-libevFor 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 installtar 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 installFor a detailed and complete list of all supported arguments, you may refer to the man pages of the applications, respectively.
…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 123.123.123.123 -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 0.0.0.0/8 -j RETURN
root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d 10.0.0.0/8 -j RETURN
root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d 127.0.0.0/8 -j RETURN
root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d 169.254.0.0/16 -j RETURN
root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d 172.16.0.0/12 -j RETURN
root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d 192.168.0.0/16 -j RETURN
root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d 224.0.0.0/4 -j RETURN
root@Wrt:~# iptables -t nat -A SHADOWSOCKS -d 240.0.0.0/4 -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.pidIt'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.
server_linux_amd64 -l :21 -t 127.0.0.1:443 --crypt none --mtu 1200 --nocomp --mode normal --dscp 46 &
ss-server -s 0.0.0.0 -p 443 -k passwd -m chacha20 -uclient_linux_amd64 -l 127.0.0.1:1090 -r :21 --crypt none --mtu 1200 --nocomp --mode normal --dscp 46 &
ss-local -s 127.0.0.1 -p 1090 -k passwd -m chacha20 -l 1080 -b 0.0.0.0 &
ss-local -s -p 443 -k passwd -m chacha20 -l 1080 -U -b 0.0.0.0Although shadowsocks-libev can handle thousands of concurrent connections nicely, we sti
No open issues yet, or sync has not completed.