Skip to content

Instantly share code, notes, and snippets.

@tomisacat
Created October 17, 2017 09:30
Show Gist options
  • Save tomisacat/bdef8e5e363856fc6c022e80db57ccb8 to your computer and use it in GitHub Desktop.
Save tomisacat/bdef8e5e363856fc6c022e80db57ccb8 to your computer and use it in GitHub Desktop.
Convenient script to install and setup shadowsocks with bbr enabled
#!/bin/bash
echo "Usage:"
echo " 1. ./vultr_ss_setup.sh"
echo " 2. ./vultr_ss_setup.sh install"
echo " 3. ./vultr_ss_setup.sh bbr"
if [ $# -lt 1 ]
then
# Start Shadowsocks
nohup ssserver -c /etc/shadowsocks.json &
exit
fi
if [ $1 = "install" ]
then
# Install Shadowsocks
yum install -y m2crypto python-setuptools
easy_install pip
pip install shadowsocks
# Configuration
touch /etc/shadowsocks.json
echo "{" >> /etc/shadowsocks.json
echo " \"server\":\"0.0.0.0\"," >> /etc/shadowsocks.json
echo " \"server_port\":443," >> /etc/shadowsocks.json
echo " \"local_address\": \"127.0.0.1\"," >> /etc/shadowsocks.json
echo " \"local_port\":1080," >> /etc/shadowsocks.json
echo " \"password\":\"majun\"," >> /etc/shadowsocks.json
echo " \"timeout\":300," >> /etc/shadowsocks.json
echo " \"method\":\"aes-256-cfb\"," >> /etc/shadowsocks.json
echo " \"fast_open\": false" >> /etc/shadowsocks.json
echo "}" >> /etc/shadowsocks.json
# Firewall
systemctl start firewalld
firewall-cmd --permanent --zone=public --add-port=443/tcp
firewall-cmd --reload
# Upgrade Kernel
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
yum --enablerepo=elrepo-kernel install kernel-ml -y
rpm -qa | grep kernel
grub2-set-default 1
shutdown -r now
fi
if [ $1 = "bbr" ]
then
# Enable BBR
uname -r
echo 'net.core.default_qdisc=fq' | sudo tee -a /etc/sysctl.conf
echo 'net.ipv4.tcp_congestion_control=bbr' | sudo tee -a /etc/sysctl.conf
sysctl -p
sysctl net.ipv4.tcp_available_congestion_control
sysctl -n net.ipv4.tcp_congestion_control
lsmod | grep bbr
fi
@tomisacat
Copy link
Author

NOTE:

It only works for operating systems which adopt yum package manager such as CentOS.

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