|
|
环境:eth0:内网ip:10.0.0.1
eth1:外网ip:122.224.x.x
1.由于centos5.2集成了ppp,所以不用安装ppp了
也可以用yum install -y ppp iptables升级一下
2.先检查系统的MPPE, 基本上CentOS本身都有, 看到ok就可继续往下,不行,就去看别人的打补丁,基本centos5.2是自带的,不用配置,检查方法如下:
modprobe ppp-compress-18 && echo ok
或:
#strings '/usr/sbin/pppd' |grep -i mppe | wc --lines
如果以上命令输出为“0”则表示不支持;输出为“30”或更大的数字就表示支持。
3.下载pptpd-1.3.4-1.rhel5.1.i386.rpm,下载地址:
wget http://poptop.sourceforge.net/yum/stable/packages/pptpd-1.3.4-1.rhel5.1.i386.rpm
4.用rpm -ivh pptpd-1.3.4-1.rhel5.1.i386.rpm,安装。
5.配置,主要配置有:
/etc/pptpd.conf
/etc/ppp/options.pptpd
/etc/ppp/chap-secrets
首先配置:/etc/pptpd.conf
localip 122.224.x.x
remoteip 10.0.200.1-254,10.0.200.245
其次配置/etc/ppp/options.pptpd
去掉下面两个参数的"#"
debug \\打开调试.这样可以在/var/log/message中看到调试结果
dump
或者
logfile /var/log/pptpd.log \\指定日志文件
在配置:/etc/ppp/chap-secrets
内容如下:
# Secrets for authentication using CHAP
# client server secret IP addresses
admin pptpd admin(密码) * (ip自动获取)
pptpd配置完成,下面配置linux系统的和pptpd相关iptables
1.开启iptables
service iptables start
2.打开转发功能
echo "1">/proc/sys/net/ipv4/ip_forward
3.打开 1723,47端口,gre协议
iptables -A INPUT -p tcp --dport 1723 -j ACCEPT
iptables -A INPUT -p tcp --dport 47 -j ACCEPT
iptables -A INPUT -p gre -j ACCEPT
或在/etc/sysconfig/iptables文件你们增加:
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 1723 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m tcp --dport 47 -j ACCEPT
注:要在client上开启远程桌面,还要开放3389端口。
4.增加转发功能
查看iptables的net转发:
iptables -t nat -L
清除iptables的nat功能
iptables -F -t nat
iptables -t nat -A POSTROUTING -s 10.0.200.0/24 -j SNAT --to-source 10.0.0.1(内网转发)
iptables -t nat -A POSTROUTING -s 10.0.200.0/24 -j SNAT --to-source 122.224.x.x(外网转发)
查看方法:
下面启动pptpd
service pptpd start
netstat -nal 看看如果开了1723,表示成功.(1723状态为LISTEN)
可以用ntsysv,启动服务列表,将pptpd服务选中,这样,每次重启动后,自启动pptpd服务
================================================
错误排除
完成以上配置,通过Windows拨号到VPN,一定提示619错误。
引发619错误的原因有很多,比如密码不正确等,都报这个错误。
我们可以通过/var/log/messages查看下日志,找到问题原因
Dec 20 06:45:12 204-74-212-217 pptpd[18317]: CTRL: Client 221.223.48.186 control connection started
Dec 20 06:45:12 204-74-212-217 pptpd[18317]: CTRL: Starting call (launching pppd, opening GRE)
Dec 20 06:45:12 204-74-212-217 pppd[18318]: Plugin /usr/lib/pptpd/pptpd-logwtmp.so is for pppd version 2.4.3, this is 2.4.4
Dec 20 06:45:12 204-74-212-217 pptpd[18317]: GRE: read(fd=6,buffer=804e5a0,len=8196) from PTY failed: status = -1 error = Input/output error, usually caused by unexpected termination of pppd, check option syntax and pppd logs
Dec 20 06:45:12 204-74-212-217 pptpd[18317]: CTRL: PTY read or GRE write failed (pty,gre)=(6,7)
Dec 20 06:45:12 204-74-212-217 pptpd[18317]: CTRL: Client 221.223.48.186 control connection finished
注意到红色部分了吧,就是这个错误。建议我们查看配置语法。
后来有找了一些文档查看,和一条一条屏蔽配置语法
发现是logwtmp这个配置选项出现问题。最后编辑/etc/pptpd.conf文件
注释掉logwtmp选项,重启pptpd服务,就可以正常登陆了。 |
|