CentOS7 安装 shadow,socks 服务端
环境
conoha vps
CentOS7.2
背景
在 conoha 买了一个 vps,准备使用 shadow,socks 搭建 vpn
1、安装shadow,socks
yum install python-setuptools && easy_install pip
pip install shadow,socks
2、在/etc/shadow,socks
新建config.json
配置文件
{
"server":"133.130.127.xxx",
"server_port":4433,
"local_address": "0.0.0.0",
"local_port":1080,
"password":"myxxx",
"timeout":600,
"method":"aes-256-cfb"
}
3、后台运行 shadow,socks 服务端程序,并把标准输出和标准错误输出重定向到/etc/shadow,socks/a.log
nohup ssserver -c /etc/shadow,socks/config.json > /etc/shadow,socks/a.log 2>&1 &
4、打开本机的 shadow,socks 客户端,对应输入config.json
配置文件中的server
、server_port
和password
,此时却发现上不了网
5、原来是 CentOS 的防火墙没有打开我们设定的 4433 端口,现在使用firewall
把端口权限打开
#打开 4433 端口(--permanent 永久生效,没有此参数重启后失效)
firewall-cmd --zone=public --add-port=4433/tcp --permanent
#重新载入 firewall
firewall-cmd --reload
注:CentOS7 的防火墙用 firewall 取代了之前的 iptables,如果你是 CentOS 的老版本用户:
iptables -I INPUT 4 -p tcp -m state --state NEW -m tcp --dport 4433 -j ACCEPT
#保存iptables规则
service iptables save