Tip: VI编辑文件时, 先找配置项是否存在,若存在,修改,反之新增
1. 安装PPTP服务器
2. 编辑/etc/pptpd.conf 文件,找到设置PPTP服务器IP地址 & PPTP客户端IP地址范围的2行取消注释(你应该改一下网段)
1 2 3
| localip 192.168.99.1 remoteip 192.168.99.234-238,192.168.99.245
|
3. 添加账号
1 2
| # vi /etc/ppp/chap-secrets xiaochunyong pptpd 123456 *
|
4. 设置DNS
1 2 3
| # vi /etc/ppp/options ms-dns 8.8.8.8 ms-dns 8.8.4.4
|
5. 设置转发 & 立即生效 & 重启PPTP服务器
1 2 3 4 5 6
| # vi /etc/sysctl.conf net.ipv4.ip_forward=1
# sysctl -p
# /etc/init.d/pptpd restart
|
6. 开启iptables转发
1 2 3 4 5
| # iptables -t nat -A POSTROUTING -s 192.168.99.0/24 -o eth1 -j MASQUERADE
### 注意(iptables的下面2个选项如果错误,VPN客户端即使连接上PPTP服务器,也不能上网) ### -s 192.168.99.0/24 : 网段/子网掩码, 必须和步骤二设置的网段一样 ### -o eth1 : 网卡
|
7. 安装iptables
1
| # apt-get install iptables
|
8. 将当前iptables的设置保存到指定文件, 以便每次重启自动还原iptables设置
1 2 3 4 5 6 7
| # iptables-save > /etc/iptables.pptp
# vi /etc/network/if-up.d/iptables #!/bin/sh iptables-restore < /etc/iptables.pptp
# chmod +x /etc/network/if-up.d/iptables
|