Centos一键安装VPN脚本

林继 VPS 知识 1,899 共写了100个字 (2012-10-12 17:02:02) 没有评论 打印 扫描二维码 百度已收录

本文来自:http://www.nigesb.com

安装vpn是比较麻烦和头疼的事情,因此分享一个一键安装vpn脚本,Centos下测试通过:

  1. yum remove -y pptpd ppp
  2. iptables --flush POSTROUTING --table nat
  3. iptables --flush FORWARD
  4. rm -rf /etc/pptpd.conf
  5. rm -rf /etc/ppp
  6.  
  7. wget http://poptop.sourceforge.net/yum/stable/packages/dkms-2.0.17.5-1.noarch.rpm  
  8. wget http://poptop.sourceforge.net/yum/stable/packages/kernel_ppp_mppe-1.0.2-3dkms.noarch.rpm
  9. wget http://poptop.sourceforge.net/yum/stable/packages/pptpd-1.3.4-2.rhel5.i386.rpm
  10. wget http://poptop.sourceforge.net/yum/stable/rhel5Server/i386/ppp-2.4.4-14.1.rhel5.i386.rpm
  11.  
  12. yum -y install make libpcap iptables gcc-c++ logrotate tar cpio perl pam tcp_wrappers
  13. rpm -ivh dkms-2.0.17.5-1.noarch.rpm
  14. rpm -ivh kernel_ppp_mppe-1.0.2-3dkms.noarch.rpm
  15. rpm -qa kernel_ppp_mppe
  16. rpm -Uvh ppp-2.4.4-14.1.rhel5.i386.rpm
  17. rpm -ivh pptpd-1.3.4-2.rhel5.i386.rpm
  18.  
  19. mknod /dev/ppp c 108 0 
  20. echo 1 > /proc/sys/net/ipv4/ip_forward 
  21. echo "mknod /dev/ppp c 108 0" >> /etc/rc.local
  22. echo "echo 1 > /proc/sys/net/ipv4/ip_forward" >> /etc/rc.local
  23. echo "localip 172.16.36.1" >> /etc/pptpd.conf
  24. echo "remoteip 172.16.36.2-254" >> /etc/pptpd.conf
  25. echo "ms-dns 8.8.8.8" >> /etc/ppp/options.pptpd
  26. echo "ms-dns 8.8.4.4" >> /etc/ppp/options.pptpd
  27.  
  28. pass=`openssl rand 6 -base64`
  29. if [ "$1" != "" ]
  30. then pass=$1
  31. fi
  32.  
  33. echo "vpn pptpd ${pass} *" >> /etc/ppp/chap-secrets
  34.  
  35. 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==1 { print $1}'`
  36. iptables -A FORWARD -p tcp --syn -s 172.16.36.0/24 -j TCPMSS --set-mss 1356
  37. service iptables save
  38.  
  39. chkconfig iptables on
  40. chkconfig pptpd on
  41.  
  42. service iptables start
  43. service pptpd start
  44.  
  45. echo "VPN service is installed, your VPN username is vpn, VPN password is ${pass}"

如果觉得我的文章对您有用,请随意赞赏。您的支持将鼓励我继续创作!

发表评论

电子邮件地址不会被公开。 必填项已用*标注

< >