大杀器服务器安装脚本使用 Squid 作为 HTTP 代理服务器
实际上,如果有需要,你可以使用任何类型的代理服务器
下面以 CentOS 6 下的 Dante 为例,介绍如何安装配置 SOCKS5 代理服务器
禁止 squid 服务自动启动
chkconfig squid off
停止 squid 服务
service squid stop
安装 C, C++ 编译器
yum install -y gcc
切换到用户目录
cd
下载文件包
wget http://www.inet.no/dante/files/dante-1.4.2.tar.gz
解压文件包
tar -xvzf dante-1.4.2.tar.gz
切换到解压目录
cd dante-1.4.2
配置、编译和安装
./configure && make && make install
切换到用户目录
cd
查看帮助
sockd -h
显示结果
Dante v1.4.2. Copyright (c) 1997 – 2014, Inferno Nettverk A/S, Norway.
usage: sockd [-DLNVdfhnv]
-D : run in daemon mode
-L : shows the license for this program
-N <number> : fork of <number> servers [1]
-V : verify configuration and exit
-d <number> : set degree of debugging
-f <filename> : use <filename> as configuration file [/etc/sockd.conf]
-h : print this information
-n : disable TCP keep-alive
-p <filename> : write pid to <filename> [/var/run/sockd.pid]
-v : print version info
创建配置文件
vi /etc/sockd.conf
加入配置信息
其中 eth0 是公网网卡名字,也可以换成公网 IP
internal: 127.0.0.1 port = 3128
external: eth0
clientmethod: none
socksmethod: none
user.notprivileged: nobody
errorlog: /var/log/sockd.err
#logoutput: /var/log/sockd.log
client pass { from: 0/0 to: 0/0 }
socks block { from: 0/0 to: lo }
socks pass { from: 0/0 to: 0/0 }
查看 sockd 所在目录
which sockd
显示结果
/usr/local/sbin/sockd
创建服务启动脚本
vi sockd-start
加入启动脚本内容
killall sockd > /dev/null 2>&1
/usr/local/sbin/sockd -D
创建服务停止脚本
vi sockd-stop
加入停止脚本内容
killall sockd > /dev/null 2>&1
设置启动、停止脚本为可执行文件
chmod +x sockd-start sockd-stop
启动服务
./sockd-start
查看进程
ps aux |grep sockd
显示结果
停止服务
./sockd-stop
设置服务开机自动启动
vi /etc/rc.local
添加内容
/root/sockd-start
浏览器使用注意事项
与 HTTP 代理不同,使用 SOCKS5 代理,浏览器需要强制设置 DNS 远程解析,才能进行翻墙
最新版的火狐 FireFox 浏览器可以设置 DNS 远程解析,其它浏览器可能需要借助第三方工具
搬瓦工 debian 9 x86_64 socks5代理
echo ;
echo ;
echo 正在安装 GFW.Press 服务器,请稍候………. ;
echo ;
cd /;
apt-get update > /dev/null ;
apt-get install default-jdk build-essential pwgen git -y -q > /dev/null ;
update-rc.d squid disabled > /dev/null ;
service squid stop > /dev/null ;
if [ -e “/gfw.press” ] ; then
echo “目录 /gfw.press 已经存在,安装退出” ;
echo ;
echo “如需重新安装,请先把目录 /gfw.press 改名或删除” ;
else
git clone https://github.com/chinashiyu/gfw.press.git ;
chmod a+x /gfw.press/server.sh ;
chmod a+x /gfw.press/stop.sh ;
for i in $( seq 20001 20101 )
do pwgen -n -s -B -c 10 | sed “s/^/$i /”;
done > /gfw.press/user.tx_ ;
rm -f /gfw.press/user.txt ;
cp /gfw.press/user.tx_ /gfw.press/user.txt ;
sed -i “s/-Xms512M/-Xms256M/g” /gfw.press/server.sh ;
sed -i “s/-Xmx512M/-Xmx256M/g” /gfw.press/server.sh ;
iptables -F ;
iptables -A INPUT -p tcp –dport 22 -j ACCEPT ;
iptables -A INPUT -p tcp –dport 80 -j ACCEPT ;
iptables -A INPUT -p tcp –dport 443 -j ACCEPT ;
iptables -A INPUT -p tcp –dport 25 -j ACCEPT ;
iptables -A INPUT -p tcp –dport 110 -j ACCEPT ;
iptables -A INPUT -p tcp –dport 20000:20100 -j ACCEPT ;
iptables -A INPUT -p tcp –dport 28040:28050 -j ACCEPT ;
iptables -P INPUT DROP ;
iptables -P FORWARD DROP ;
iptables -P OUTPUT ACCEPT ;
iptables -A INPUT -i lo -j ACCEPT ;
iptables -A INPUT -m state –state ESTABLISHED,RELATED -j ACCEPT ;
iptables -A INPUT -p icmp -j ACCEPT ;
iptables-save > /dev/null ;
fi;
cd /root ;
mkdir sockd;
cd sockd;
wget http://www.inet.no/dante/files/dante-1.4.2.tar.gz;
tar -xvzf dante-1.4.2.tar.gz > /dev/null ;
cd dante-1.4.2;
./configure > /dev/null ;
make > /dev/null ;
make install > /dev/null ;
cd ..;
#创建配置文件
echo internal: 127.0.0.1 port = 3128 > /etc/sockd.conf;
echo external: eth0 >> /etc/sockd.conf;
echo clientmethod: none >> /etc/sockd.conf;
echo socksmethod: none >> /etc/sockd.conf;
echo user.notprivileged: nobody >> /etc/sockd.conf;
echo errorlog: /var/log/sockd.err >> /etc/sockd.conf;
echo client pass { from: 0/0 to: 0/0 } >> /etc/sockd.conf;
echo socks block { from: 0/0 to: lo } >> /etc/sockd.conf;
echo socks pass { from: 0/0 to: 0/0 } >> /etc/sockd.conf;
#创建服务启动脚本
echo “killall sockd > /dev/null 2>&1” > sockd-start.sh;
echo /usr/local/sbin/sockd -D >> sockd-start.sh;
#创建服务停止脚本
echo “killall sockd > /dev/null 2>&1” > sockd-stop.sh;
#设置启动、停止脚本为可执行文件
chmod +x sockd-start.sh sockd-stop.sh
echo “/root/sockd/sockd-start.sh” >> /etc/rc.local;
echo ;
echo “已完成 GFW.Press 服务器安装” ;
echo ;
echo “启动sockd请执行 /root/sockd/sockd-start.sh ” ;
echo ;
echo “端口和密码在文件 /gfw.press/user.txt” ;
echo ;
echo “启动服务器请执行 /gfw.press/server.sh ” ;
echo ;
echo ;
想变成您一样的懂技术原理能灵活调整参数应对gfw升级的人,有哪些技术类入门参考书推荐啊?我大概在python网络方向读过一些代码
谢谢
鸟哥的Linux私房菜,然后 shell编程,正则表达式,用到什么学什么,不要钻进去了。