1.安装pptpd
[root@VM_0_6_centos etc]# yum install -y pptpd
2.对虚拟专用网络进行IP段分配
[root@VM_0_6_centos etc]# vim /etc/pptpd.conflocalip 193.112.40.37 remoteip 172.16.1.120-200
3.指定DNS写入文件末尾即可
[root@VM_0_6_centos etc]# vim /etc/ppp/options.pptpdms-dns 8.8.8.8 ms-dns 8.8.4.4
4.配置用户名和密码
[root@VM_0_6_centos etc]# vim /etc/ppp/chap-secrets# Secrets for authentication using CHAP# client server secret IP addressesxingyulin pptpd 123456 *
5、开启IP转发
[root@VM_0_6_centos etc]# vim /etc/sysctl.conf#将“net.ipv4.ip_forward = 0”改为“net.ipv4.ip_forward = 1”# Controls IP packet forwardingnet.ipv4.ip_forward =1
转发生效
[root@VM_0_6_centos etc]# sysctl -p
6.配置转发策略以及开放常用的端口
[root@VM_0_6_centos ppp]# iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE[root@VM_0_6_centos ppp]# iptables -A INPUT -p tcp -m tcp --dport 21 -j ACCEPT[root@VM_0_6_centos ppp]# iptables -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT[root@VM_0_6_centos ppp]# iptables -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT[root@VM_0_6_centos ppp]# iptables -A INPUT -p tcp -m tcp --dport 1723 -j ACCEPT
7、重启pptpd服务
[root@VM_0_6_centos etc]# systemctl start pptpd.service#检查状态active (running)为成功[root@VM_0_6_centos etc]# systemctl status pptpd.service● pptpd.service - PoPToP Point to Point Tunneling Server Loaded: loaded (/usr/lib/systemd/system/pptpd.service; enabled; vendor preset: disabled) Active: active (running) since 五 2019-01-0411:15:53 CST; 4h 17min ago Main PID: 19053 (pptpd) CGroup: /system.slice/pptpd.service └─19053 /usr/sbin/pptpd -f
8.链接虚拟专用网络测试