Skip to content

Instantly share code, notes, and snippets.

@aditsachde
Last active August 29, 2019 17:16
Show Gist options
  • Save aditsachde/94c650210056a092809df40356f7725c to your computer and use it in GitHub Desktop.
Save aditsachde/94c650210056a092809df40356f7725c to your computer and use it in GitHub Desktop.

Installing Shadowsocks with v2-ray

Start by installing all the dependencies

#Start by installing shadowsocks
sudo apt update
sudo apt-get install shadowsocks-libev -y

#Install tmux, used to create the daemon
sudo apt-get install tmux -y

#Now, install the v2-ray plugin
wget -qO- https://github.com/shadowsocks/v2ray-plugin/releases/download/v1.1.0/v2ray-plugin-linux-amd64-v1.1.0.tar.gz | sudo tar xvz -C /etc/shadowsocks-libev/

These following commands can be copied and pasted. They optimize the server networking protocols

echo '* soft nofile 51200' >> /etc/security/limits.conf
echo '* hard nofile 51200' >> /etc/security/limits.conf
ulimit -n 51200

rm /etc/sysctl.conf

echo 'fs.file-max = 51200
net.core.rmem_max = 67108864
net.core.wmem_max = 67108864
net.core.netdev_max_backlog = 250000
net.core.somaxconn = 4096
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 1200
net.ipv4.ip_local_port_range = 10000 65000
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.tcp_fastopen = 3
net.ipv4.tcp_mem = 25600 51200 102400
net.ipv4.tcp_rmem = 4096 87380 67108864
net.ipv4.tcp_wmem = 4096 65536 67108864
net.ipv4.tcp_mtu_probing = 1
net.ipv4.tcp_congestion_control = hybla' >> /etc/sysctl.conf

sysctl -p

curl -sSL https://raw.githubusercontent.com/LiveChief/tcp-bbr-install/master/bbr.sh | bash
uname -r
sysctl net.ipv4.tcp_available_congestion_control
sysctl net.ipv4.tcp_congestion_control
sysctl net.core.default_qdisc
lsmod | grep bbr

sysctl -p

Now we create a config file

Change the password to something secure

{
    "server":"0.0.0.0",
    "server_port":80,
    "password":"PASSWORD",
    "timeout":300,
    "user":"nobody",
    "method":"chacha20-ietf-poly1305",
    "fast_open":false,
    "reuse_port":true,
    "no_delay":true,
    "plugin":"/etc/shadowsocks-libev/v2ray-plugin_linux_amd64",
    "plugin_opts":"server"
}

Now we install the config file

Type nano /etc/shadowsocks-libev/config.json Copy full the previous code block into this file, including the braces.

Now we start the server

Type tmux This will open another terminal with a green bar at the bottom. Now, start the server by typing ss-server Lastly, type Ctrl-B D. This will detach the tmux session. To later get back into the tmux shell, type tmux attach At this point, you can exit the ssh session by typing exit

Client setup

On andriod, ensure you have Shadowsocks and V2ray Plugin installed, both by Max Lv. Click plus and click manual settings.

IP: server IP
Remote Port: 80
Password: from above
Encrypt Method: chacha20-ietf-poly1305

Plugin: v2ray
Under configure plugin:
Transport mode: websocket-http

Windows is very similar, but download the plugin from this link

Extract into the same folder as the shadowsocks.exe used to launch shadowsocks, and rename the plugin to v2ray.exe. In shadowsocks, enter v2ray as the plugin, and leave plugin options empty.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment