1,安装pptpd
sudo apt-get install pptpd
2,配置虚拟ip,编辑 /etc/pptpd.conf
localip 192.168.0.1
remoteip 192.168.0.200-210,192.168.0.245
3,设置dns,编辑 /etc/ppp/pptpd-options
ms-dns 8.8.8.8
ms-dns 8.8.4.4
4,添加用户,编辑 /etc/ppp/chap-secrets
user pptpd 123456 *
5,重启pptpd
6,配置NAT流量转发,编辑/etc/sysctl.conf
net.ipv4.ip_forward=1
7,使得配置立即生效
sudo sysctl –p
8,向iptables添加NAT规则
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE
iptables-save > /etc/iptables-rules-for-me
9,新建 /etc/network/if-pre-up.d/iptables,添加内容
#!/bin/sh
iptables-restore < /etc/iptables-rules-for-me