vps构建。

只是凑数。往后完善。
CentOS_7 安装shadowsocks 主机提供商Linode

putty登录主机

yum install -y iptables-services #安装iptables
systemctl enable iptables   #开机启动ipables
systemctl start iptables   #现在启动ipables
vim /etc/iptables.firewall.rules #创建防火墙规则(借用Linode自家的规则) 本规则只开放443、80端口以及ssh的22 端口。
输入:(%号区域内的内容)
%%%%%%%%%%%
*filter

#  Allow all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0
-A INPUT -i lo -j ACCEPT
-A INPUT -d 127.0.0.0/8 -j REJECT

#  Accept all established inbound connections
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT

#  Allow all outbound traffic - you can modify this to only allow certain traffic
-A OUTPUT -j ACCEPT

#  Allow HTTP and HTTPS connections from anywhere (the normal ports for websites and SSL).
-A INPUT -p tcp --dport 80 -j ACCEPT
-A INPUT -p tcp --dport 443 -j ACCEPT

#  Allow SSH connections
#
#  The -dport number should be the same port number you set in sshd_config
#
-A INPUT -p tcp -m state --state NEW --dport 22 -j ACCEPT

#  Allow ping
-A INPUT -p icmp --icmp-type echo-request -j ACCEPT

#  Log iptables denied calls
-A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7

#  Drop all other inbound - default deny unless explicitly allowed policy
-A INPUT -j DROP
-A FORWARD -j DROP

#  Allow incoming Longview connections
-A INPUT -s longview.linode.com -j ACCEPT

# Allow metrics to be provided Longview
-A OUTPUT -d longview.linode.com -j ACCEPT

COMMIT
%%%%%%%%%%
sudo iptables-restore < /etc/iptables.firewall.rules #保存后执行
iptables -L -n  -v   #查看规则是否一致
/sbin/service iptables save   #保存iptables规则
Ⅱ-安装shadowsocks
yum install epel-release #安装第三方软件库(不然没法安装 supervisord)
yum install m2crypto python-setuptools python-pip supervisor #安装SS所需
pip install shadowsocks #安装ss
vim /etc/shadowsocks.json  (该配置文件为多用户,如果不需要的网上自行查找,多数都是单用户配置。双引号内的0.0.0.0改写成自己服务器ip)
写入:(%号区域内的内容)
%%%%%%%%%%
{
    "server":"0.0.0.0",
    "port_password":{
                        "port1":"password1",
                        "port2":"password2",
                        "port3":"password3"
 },
    "local_address": "127.0.0.1",
    "local_port":1080,
    "timeout":200,
    "method":"aes-256-cfb",
    "fast_open": true,
    "workers": 1
}
%%%%%%%%%%
vim /etc/supervisord.d/shadowsocks.ini   #编辑ss启动配置
写入:(%号区域内的内容)
%%%%%%%%%%
[program:shadowsocks]
command=ssserver -c /etc/shadowsocks.json
autostart=true
autorestart=true
user=root
redirect_stderr=true
stdout_logfile=/var/log/ss5.log
%%%%%%%%%%
systemctl enable supervisord   #使supervisord开机启动
systemctl start supervisord   #当前启动supervisord
ps -e #检查 是否有ssserver和supervisord

评论