Created
October 17, 2017 09:30
-
-
Save tomisacat/bdef8e5e363856fc6c022e80db57ccb8 to your computer and use it in GitHub Desktop.
Convenient script to install and setup shadowsocks with bbr enabled
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
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
First, you should copy this file to your VPS via
scp
:then login via
ssh
andchmod +x ./shadowsocks_setup.sh
Usage
Install
Shadowsocks
:./shadowsocks_setup.sh install
Enable
BBR
:./shadowsocks_setup.sh bbr
Start
Shadowsocks
:./shadowsocks_setup.sh