安装PPP
ppp协议是pptp vpn必须要的组件,使用yum快速安装:
yum install ppp
安装完成后,会生出配置文件目录:/etc/ppp。
安装pptpd
下载pptpd源码包:http://sourceforge.net/projects/poptop/files/pptpd/
编译安装,很简单
./configure --prefix=/opt/program/pptpd make make install
配置
先复制pptpd源码包中的配置文件
#pptpd的主要配置,放在etc目录下面 cp /opt/setup/pptpd-setup/pptpd-1.3.4/samples/pptpd.conf /etc/pptpd.conf #pptpd的第二个配置 cp /opt/setup/pptpd-setup/pptpd-1.3.4/samples/options.pptpd /etc/ppp/options.pptpd
修改pptp.conf文件
#在文件末尾加入下面三行(最后一行为空白行): localip 10.0.0.1 remoteip 10.0.0.2-254 #注意,pptpd.conf文件末尾需要空一行空白行,不然启动服务时会报错。
修改options.pptpd文件
#修改ms-dns,设置连上vpn后,分配给客户端的DNS地址 ms-dns 8.8.8.8 ms-dns 8.8.4.4
修改/etc/ppp/chap-secrets文件
#定义VPN连接账号,用户名为liming,密码为myvpnpptpd # Secrets for authentication using CHAP # client server secret IP addresses liming pptpd myvpnpptpd *
修改防火墙iptables配置
#第一个允许转发,第二个开放pptpd服务的端口1723 iptables -A POSTROUTING -s 10.0.0.0/24 -j SNAT --to-source 服务器对外IP地址 iptables -A INPUT -i eth0 -p tcp -m tcp --sport 1024:65534 --dport 1723 -j ACCEPT service iptables save
创建init文件
#!/bin/sh # # Startup script for pptpd # # chkconfig: - 85 15 # description: PPTP server # processname: pptpd # config: /etc/pptpd.conf # Source function library. . /etc/rc.d/init.d/functions # See how we were called. case "$1" in start) echo -n "Starting pptpd: " if [ -f /var/lock/subsys/pptpd ] ; then echo exit 1 fi daemon /opt/program/pptpd/sbin/pptpd echo touch /var/lock/subsys/pptpd ;; stop) echo -n "Shutting down pptpd: " killproc pptpd echo rm -f /var/lock/subsys/pptpd ;; status) status pptpd ;; condrestart) if [ -f /var/lock/subsys/pptpd ]; then $0 stop $0 start fi ;; reload|restart) $0 stop $0 start echo "Warning: a pptpd restart does not terminate existing " echo "connections, so new connections may be assigned the same IP " echo "address and cause unexpected results. Use restart-kill to " echo "destroy existing connections during a restart." ;; restart-kill) $0 stop ps -ef | grep pptpd | grep -v grep | grep -v rc.d | awk '{print $2}' | uniq | xargs kill 1> /dev/null 2>&1 $0 start ;; *) echo "Usage: $0 {start|stop|restart|restart-kill|status}" exit 1 esac exit 0
最后,修改/etc/inti.d/pptpd文件的权限,允许运行。
启动服务,在客户端新建一个vpn连接,应该是没问题了。