pptpd是一个比较简单的vpn服务,安装简单,而且一般设备也都自带客户端,若有需要,可以参考一下下面的安装步骤。
首先需要下载pptpd的安装包。
上传到服务器上,通过yum安装。
yum localinstall pptpd-1.4.0-3.el6.x86_64.rpm
配置pptpd开机启动
chkconfig pptpd on
编辑/etc/sysctl.conf更改内核参数,更改下面选项。
net.ipv4.ip_forward = 1
执行 sysctl -p 立即生效。
更改/etc/pptpd.conf,为vpn分配隧道ip,为用户分配ip地址。
localip 10.8.8.1 remoteip 10.8.8.100-200
修改/etc/ppp/options.pptpd,为用户指定dns。
ms-dns 114.114.114.114 ms-dns 8.8.8.8
修改/etc/ppp/chap-secrets,添加vpn用户。分别是用户名、pptpd、密码、ip地址(*表示随机分配ip)。
# Secrets for authentication using CHAP # client server secret IP addresses internelp pptpd pass *
添加iptables配置,使其支持转发。不然只可以拨号,但无法访问外网。
iptables -t nat -A POSTROUTING -s 10.8.8.0/24 -o eth1 -j SNAT --to-source 115.2.4.5 service iptables save -------说明----- 10.8.8.0/24 #表示是vpn用户的ip,在pptpd.conf中配置过。 eth1 #表示哪个网卡连接到Internet。 115.2.4.5 #表示eth1的ip地址,连接到Internet的地址。 -------如果使用了iptables仅开放白名单端口还需要添加下面的策略------- iptables -A INPUT -p tcp --dport 1723 -j ACCEPT iptables -A INPUT -p gre -j ACCEPT
错误解决
可以查看/var/log/message日志查看错误,可以参考下面,我第一次配置ip地址的时候配置错误,pptpd服务就无法启动。。
Aug 27 11:50:08 qiansw pptpd[1482]: MGR: Bad IP address (10.8.8.100-10.8.8.200) in config file! Aug 27 11:50:14 qiansw pptpd[1523]: MGR: Bad IP address (10.8.8.100-10.8.8.200) in config file! Aug 27 11:50:23 qiansw pptpd[1548]: MGR: Bad IP address (10.8.8.100-10.8.8.200) in config file!
下面的错误我测试了半天,最后发现是我们本地的路由器给阻挡了。。。
Using interface ppp0 Connect: ppp0 < --> /dev/pts/3 MGR: initial packet length 18245 outside (0 - 220) LCP: timeout sending Config-Requests Connection terminated. Modem hangup Exit. GRE: read(fd=6,buffer=6124a0,len=8196) from PTY failed: status = -1 error = Input/output error, usually caused by unexpected termination of pppd, check option syntax and pppd logs CTRL: PTY read or GRE write failed (pty,gre)=(6,7) CTRL: Client 118.186.255.177 control connection finished
某些网站打不开:
修改mtu。
编辑/etc/ppp/ip-up文件,在exit前面加入下面文本:
/sbin/ifconfig $1 mtu 1436
这篇文章还没有人留言,快来抢沙发吧。