[h1]安裝 VPN PPTPD 於 Ubuntu 18.04.2~5 LTS [/h1]
1. 安裝
代碼:apt-get install pptpd
2. 修改 sysctl.conf IPv4 forward
代碼:vim /etc/sysctl.conf
Enable => net.ipv4.ip_forward=1
3. 重新載入 sysctl
代碼:sysctl -p
4. 編輯 IP range
代碼:vim /etc/pptpd.conf
localip 192.168.0.1
remoteip 192.168.2-250
5. 設定 Ubuntu 18.04 rcl.occal (預設 service disabled,沒有跑起來)
代碼:systemctl enable rc-local.service
systemctl restart rc-local.service
touch /etc/rc.local
chmod 755 /etc/rc.local
6. 使用 iptables 設定 NAT (OUTIF = WAN) , 並設定於 rc.local 每次載入
代碼:
OUTIF=`/sbin/ip route show to exact 0/0 | sed -r 's/.*dev\s+(\S+).*/\1/'`
iptables --table nat --append POSTROUTING --out-interface $OUTIF --jump MASQUERADE
CMD="iptables --table nat --append POSTROUTING --out-interface $OUTIF --jump MASQUERADE"
echo "$i$CMD" >> /etc/rc.local
7. Add pptpd user/password
代碼:USER="your-user-name"
KEY="your-password"
echo "$USER pptpd $KEY *" | tee -a /etc/ppp/chap-secrets
8. Check again the setup
代碼:
cat /etc/ppp/chap-secrets
cat /etc/rc.local
cat /etc/pptpd.conf
9. Start the VPN pptpd service
代碼:service pptpd restart
service pptpd status
(2019-02-28 20:36)