1、安装所需组件:

a)可以通过yum安装的包括ppp、dkms和ppp-devel

[root@ip-172-31-19-108 ~]# yum install ppp -y

[root@ip-172-31-19-108 ~]# yum install dkms -y

[root@ip-172-31-19-108 pptpd]# yum install -y ppp-devel

b)手动安装pptpd组件

可以到下面地址下载rpm安装包

http://poptop.sourceforge.net/yum/stable/packages/

为了方便,我将rpm包和配置文件均打包一起,可以直接安装使用。

[root@ip-172-31-19-108 ~]# tar jxf pptpd_20150728.tar.bz2

[root@ip-172-31-19-108 ~]# ls

pptpd  pptpd_20150728.tar.bz2

[root@ip-172-31-19-108 ~]# cd pptpd

[root@ip-172-31-19-108 pptpd]# ls

chap-secrets                options.pptpd                          pptpd-1.4.0-1.el6.x86_64.rpm       rc.local

dkms-2.0.17.5-1.noarch.rpm  ppp-2.4.5-33.0.rhel6.x86_64.rpm        pptpd.conf

options                     ppp-devel-2.4.5-33.0.rhel6.x86_64.rpm  pptp-release-4-7.rhel6.noarch.rpm

[root@ip-172-31-19-108 pptpd]#

2、配置防火墙

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

iptables -A POSTROUTING -t nat -s 192.168.0.0/24 -o eth0 -j MASQUERADE

iptables -A INPUT -p UDP –dport 53 -j ACCEPT

以上命令可以放在/etc/rc.local文件中,每次系统启动时,自动执行。

3、配置sysctl.conf

# Controls IP packet forwarding

net.ipv4.ip_forward = 1

将ip_forware的值由0改为1。

4、配置/etc/pptp.conf

在文件最后,添加以下内容:

localip 192.168.0.1

remoteip 192.168.0.100-199

5、配置/etc/ppp/options.pptpd

在文件最后,添加以下内容:

ms-dns  8.8.8.8

ms-dns  8.8.4.4

6、添加vpn用户名和密码

在配置文件/etc/pppt/chap-secrets中添加用户名和密码。

示例:

[root@ip-172-31-19-108 pptpd]# cat chap-secrets

# Secrets for authentication using CHAP

# client     server       secret                         IP addresses

   linux          pptpd  linux *

添加用户linux,密码也为linux。

7、生效以上配置,然后启动pptpd服务

  source /etc/rc.local

  sysctl -p

  service pptpd start

8、将pptpd加入系统服务(可选)

  chkconfig –add pptpd

  chkconfig  –level 2345 pptpd on

 

到现在为止,就可以VPN服务器已经启动,在电脑或者手机上,设置登录即可。

收藏 打印