1
LetFoxRun 2013-12-03 21:03:51 +08:00
需要设置下iptables。
|
2
jhytxy OP iptables怎么设。。。
|
3
jhytxy OP sh内容如下。确实要改。不过我不会
#!/bin/bash PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin export PATH clear CUR_DIR=$(pwd) if [ $(id -u) != "0" ]; then printf "Error: You must be root to run this script!" exit 1 fi echo "#############################################################" echo "# PPTP VPN Auto Install for OpenVZ" echo "# Env: Debian/Ubuntu" echo "# Author Url: http://diahosting.com && http://wangyan.org" echo "# Modified by http://99way.com on 2011.12.29" echo "# Version: 1.0" echo "#############################################################" echo "" apt-get -y update apt-get -y install pptpd sed -i 's/exit\ 0/#exit\ 0/' /etc/rc.local mknod /dev/ppp c 108 0 echo "mknod /dev/ppp c 108 0" >> /etc/rc.local sed -i 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/g' /etc/sysctl.conf sysctl -p echo echo 1 \> \/proc\/sys\/net\/ipv4\/ip_forward >> /etc/rc.local echo exit 0 >> /etc/rc.local cat >>/etc/pptpd.conf< <EOF localip 172.16.36.1 remoteip 172.16.36.2-254 EOF cp /etc/ppp/pptpd-options /etc/ppp/pptpd-options.old cat >/etc/ppp/pptpd-options< <EOF name pptpd refuse-pap refuse-chap refuse-mschap require-mschap-v2 require-mppe-128 ms-dns 8.8.8.8 ms-dns 8.8.4.4 proxyarp #debug #dump lock nobsdcomp novj novjccomp logfile /var/log/pptpd.log EOF echo vpn pptpd 123 \* >> /etc/ppp/chap-secrets iptables-save > /etc/iptables.down.rules iptables -t nat -A POSTROUTING -s 172.16.36.0/24 -j SNAT --to-source `ifconfig | grep 'inet addr:'| grep -v '127.0.0.' | cut -d: -f2 | awk 'NR==1 { print $1}'` iptables -A FORWARD -p tcp --syn -s 172.16.36.0/24 -j TCPMSS --set-mss 1356 iptables-save > /etc/iptables.up.rules cat >>/etc/network/if-pre-up.d/iptables< <EOF #!/bin/bash /sbin/iptables-restore < /etc/iptables.up.rules EOF chmod +x /etc/network/if-pre-up.d/iptables /etc/init.d/pptpd restart |
4
iZr 2013-12-03 21:29:44 +08:00
美团云可以翻墙?
|
5
kimi4ysr 2013-12-03 23:37:51 +08:00 1
目测问题处在这里 `ifconfig | grep 'inet addr:'| grep -v '127.0.0.' | cut -d: -f2 | awk 'NR==1 { print $1}'
一般双网卡的主机,外网的IP会在第一块网卡上,类似BuyVM那样,但是美团的主机外网IP在第二块网卡上,所以可以将 NR==1 改成 NR==2 试试看 |
6
jhytxy OP @kimi4ysr 试过了。还是没有用。最后显示server是变成2号的外网ip了。但是连上以后还是没有收到来自server的数据包。我觉得是iptables缺少了东西。
|
7
iced 2013-12-04 08:42:02 +08:00
@iZr 有时候,企业内部的墙比围墙更高。比如说:上班时间不能双11、双12狂欢啊~用上国内VPN,立即可以happy了,而且因为是国内线路,速度杠杠的
|
8
jasontse 2013-12-04 09:09:06 +08:00 via iPad 1
iptables -t nat -A POSTROUTING -s 172.16.36.0/24 -o eth1 -j MASQUERADE
|
9
junyi 2013-12-04 11:04:25 +08:00 1
在这个脚本基础上修改了一下,经测试可以OK(主要修改的地方在网卡和DNS配置那块儿,请自行vimdiff),测试平台是MOS的Ubuntu 12.04 。
#!/bin/bash if [ $(id -u) != "0" ]; then printf "Error: You must be root to run this tool!\n" exit 1 fi clear printf " #################################################### # # # This is a Shell-Based tool of pptp installation # # Version: 0.1 # # Author: Bruce Ku # # For Debian/Ubuntu 32bit and 64bit # # # #################################################### " vpsip=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk 'NR==2 { print $1}'` apt-get update apt-get --purge remove pptpd ppp rm -rf /etc/pptpd.conf rm -rf /etc/ppp apt-get install -y ppp apt-get install -y pptpd apt-get install -y iptables logrotate tar cpio perl rm -r /dev/ppp mknod /dev/ppp c 108 0 echo 1 > /proc/sys/net/ipv4/ip_forward echo "mknod /dev/ppp c 108 0" >> /etc/rc.local echo "echo 1 > /proc/sys/net/ipv4/ip_forward" >> /etc/rc.local echo "localip 172.16.36.1" >> /etc/pptpd.conf echo "remoteip 172.16.36.2-254" >> /etc/pptpd.conf echo "ms-dns 8.8.8.8" >> /etc/ppp/pptpd-options echo "ms-dns 8.8.4.4" >> /etc/ppp/pptpd-options echo "test * test123 *" >> /etc/ppp/chap-secrets /etc/init.d/pptpd restart iptables -F iptables -t nat -F iptables -t nat -A POSTROUTING -s 172.16.36.0/24 -j SNAT --to-source `ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk 'NR==2 { print $1}'` iptables -A FORWARD -p tcp --syn -s 172.16.36.0/24 -j TCPMSS --set-mss 1356 iptables -t nat -A POSTROUTING -s 172.16.36.0/24 -j SNAT --to-source "$vpsip" printf " #################################################### # # # This is a Shell-Based tool of pptp installation # # Version: 0.1 # # Author: Bruce Ku # # For Debian/Ubuntu 32bit and 64bit # # # #################################################### ServerIP:$vpsip username:test password:test123 " BTW :我们都按小时计费并出API(兼容AWS EC2)了,马上可以灵活配置所有资源,其实可以不算作VPS了吧。 |
11
jhytxy OP |