搭建过程都一样参照网上的:检查服务器是否有必要的支持。命令:
modprobe ppp-compress-18 && echo ok
这条执行执行后,显示“ok”则表明通过。不过接下来还需要做另一个检查,输入指令:
cat /dev/net/tun
如果显示如下信息,说明通过,如果不支持,可以给vps商发ticket开通tun,大部分美国vps商都可以支持:
cat: /dev/net/tun: File descriptor in bad state
上面的两个只要一条通过,就能安装×××(pptp)
首先配置×××需要安装相关的软件:
yum install -y wget perl ppp
使用wget下载***安装程序:
wget http://poptop.sourceforge.net/yum/stable/packages/pptpd-1.4.0-1.el6.i686.rpm
rpm -ivh pptpd-1.4.0-1.el6.i686.rpm
配置***中的dns服务器:
cat >>/etc/ppp/options.pptpd<
ms-dns 8.8.8.8
ms-dns 8.8.8.4
EOF
配置×××中分配的IP地址
cat>>/etc/pptpd.conf<
localip 192.168.6.1
remoteip 192.168.6.2-254
EOF
配置×××中和帐号和密码
cat>>/etc/ppp/chap-secrets<
***test pptpd 654321 *
EOF
修改内核设置,使其支持转发。编辑/etc/sysctl.conf文件:
vi /etc/sysctl.conf
将“net.ipv4.ip_forward”改为1:
net.ipv4.ip_forward=1
同时在“net.ipv4.tcp_syncookies = 1”前面加# :
#net.ipv4.tcp_syncookies = 1
防火墙添加规则:
iptables -t nat -A POSTROUTING -s 192.168.6.0/255.255.255.0 -j SNAT --to-source 10.10.10.232
iptables -A FORWARD -p tcp --syn -s 192.168.6.0/255.255.255.0 -j TCPMSS --set-mss 1356
iptables -t nat -A POSTROUTING -s 192.168.0.0/255.255.255.0 -o eth0 -j MASQUERADE
iptables -A INPUT -p tcp --dport 1723 -j ACCEPT
iptables -AINPUT -s 192.168.6.0/255.255.255.0 -j ACCEPT
iptables -AINPUT -p UDP --dport 53 -j ACCEPT
#//10.10.10.232本机IP
启动×××服务并设置为自启动
service pptpd start
chkconfig pptpd on
servicepptpd restart-kill ; service pptpd start
配置完毕:
more /etc/pptpd.conf |grep -v ^#
option /etc/ppp/options.pptpd
localip 192.168.6.1
remoteip 192.168.6.2-254
more /etc/ppp/options.pptpd|grep -v ^#
name pptpd
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
require-mppe-128
ms-dns 8.8.8.8
ms-dns 8.8.8.4
proxyarp
lock
nobsdcomp
novj
novjccomp
nologfd
以上配置一直报619错误:
看到网上好多攻略;
1.rm /dev/ppp
mknod /dev/ppp c 108 0
2.还不管用的(有时出现错误651),/var/log/messages 查看日志,最后发现:
Jan 2 07:26:11 fr pptpd[1604]: CTRL:Starting call (launching pppd, opening GRE) Jan 2 07:26:11 fr pppd[1605]:Plugin /usr/lib/pptpd/pptpd-logwtmp.so is for pppd version 2.4.3, this is 2.4.5 Jan2 07:26:11 fr pptpd[1604]: GRE: read(fd=6,buffer=804fa20,len=8196) from PTYfailed: status = -1 error = Input/output error, usually caused by unexpectedtermination of pppd, check option syntax and pppd logs Jan 2 07:26:11 fr pptpd[1604]:CTRL: PTY read or GRE write failed (pty,gre)=(6,7) Jan 2 07:26:11 frpptpd[1604]: CTRL: Client X.X.X.X control connection finished
logwtmp插件版本不兼容出错了!
vi /etc/pptpd.conf
找到logwtmp,在前面加#
service pptpd restart 仍然报错无法登陆;
3.tail -100f /var/log/messages
Aug 12 20:25:34 localhost pppd[9614]: The remote system is required to authenticate itself
Aug 12 20:25:34 localhost pppd[9614]: but I couldn't find any suitable secret (password) for it to use to do so.
错误提示是认证错误,这里千万注意第二步设置用户时候的格式。
网上给解决方法:在配置文件/etc/ppp/options末尾添加上noauth即可。好像还是上不去继续报错……
网上也有怀疑路由设置问题,这次排除下来不是路由引起的;
最终是用户设置用户名加上引号就可以欢快上去了
vim /etc/ppp/chap-secrets
# Secrets for authentication using CHAP
# client server secret IP addresses
"username" pptpd "password" *
问题得到解决!
peer from calling number 10.10.10.91 authorized
Aug 12 20:32:21 localhost pppd[9913]: MPPE 128-bit stateless compression enabled
Aug 12 20:32:24 localhost pppd[9913]: Cannot determine ethernet address for proxy ARP
Aug 12 20:32:24 localhost pppd[9913]: local IP address 192.168.6.1
Aug 12 20:32:24 localhost pppd[9913]: remote IP address 192.168.6.2
有时候一个标点符号,一个字符都会导致莫名问题,出问题找日志总有办法解决的~