标签:linux pptp
#!/bin/bash #获取当前主机的IP地址(根据网卡名称修改eth0) #注意:如果你的网卡名称不是eth0,那么请你修改 HostIP=$(ifconfig eth0 | awk -F‘[ :]+‘ ‘$0 ~ "inet addr" {print $4}‘) if [ -z $HostIP ];then echo "Host IP Address Not Get!" exit 1 fi #安装pptpd服务端 yum install epel-release -y || exit 2 yum install pptpd -y || exit 2 #开启转发 echo 1 > /proc/sys/net/ipv4/ip_forward echo "echo 1 > /proc/sys/net/ipv4/ip_forward" >> /etc/rc.local #配置pptpd分配给客户端的IP地址 REMOTEIP="192.168.110.0" echo "localip $HostIP" >> /etc/pptpd.conf echo "remoteip $REMOTEIP-200" >> /etc/pptpd.conf #添加客户端的dns echo "ms-dns 8.8.8.8" >> /etc/ppp/options.pptpd echo "ms-dns 8.8.4.4" >> /etc/ppp/options.pptpd #客户端生成密码 pass=$(mkpasswd -l 20) if [ -z $1 ];then pass=$1 fi #/etc/ppp/chap-secrets文件格式: #UserName pptpd UserPass IPAddress #xiaomo pptpd fuckyou!@#321 192.168.110.100 echo "vpn pptpd ${pass} *" >> /etc/ppp/chap-secrets #nat上网 iptables -t nat -A POSTROUTING -s $REMOTEIP/24 -j SNAT --to-source $HostIP >> /etc/rc.local iptables -A FORWARD -p tcp --syn -s $REMOTEIP/24 -j TCPMSS --set-mss 1356 >> /etc/rc.local chkconfig pptpd on /etc/init.d/pptpd start echo "pptpd安装成功, 你的用户为vpn,密码为${pass}"
本文出自 “逢场做戏。” 博客,请务必保留此出处http://xiaofengmo.blog.51cto.com/10116365/1768564
标签:linux pptp
原文地址:http://xiaofengmo.blog.51cto.com/10116365/1768564