安裝pptp client
sudo apt-get update -y sudo apt-get upgrade -y sudo apt-get install -y pptp-linux
查看一下help指令用法
Setup and configuration The pptp-linux installation includes the very useful Perl script pptpsetup that is found at /usr/sbin/pptpsetup. List the help options for pptpsetup. pptpsetup --help pptpsetup has 6 options to create a PPTP connection configuration. pptpsetup --create [tunnel name] --server [vpn server] --username [vpn server username] --password [vpn server password] --encrypt (optional) --start (optional)
將以下xxxxx的部份改成你pptp server相關設定
sudo pptpsetup --create tonyhack --server hack.twgg.org --username xxxx --password xxxx --encrypt --start
這行是預設路由都往ppp0走
sudo route add -net "0.0.0.0/0" dev "ppp0"
Using interface ppp0 Connect: ppp0 <--> /dev/pts/2 CHAP authentication succeeded MPPE 128-bit stateless compression enabled local IP address 192.168.1.100 remote IP address 192.168.1.253
刪除ppp連線後的設定檔
sudo pptpsetup --delete [tunnel name]
檢查連線的資料
sudo ls -l /etc/ppp/peers/ sudo cat /etc/ppp/peers/tonyhack sudo pon tonyhack debug dump sudo pon tonyhack debug dump > ~/tonyhack-debug.txt cat ~/tonyhack-debug.txttail -f /var/log/messages sudo pon -h sudo poff -h
netstat -a | grep "/var/run/pptp/"
查看介面
ifconfig -s
刪除連線
sudo poff -a
ifconfig -s
加入開機啟動編輯/etc/rc.local
sudo nano -B /etc/rc.local
vpn="on" if [ $vpn = on ]; then printf "\nVPN connection to ProXPN UK\n" pon tonyhack updetach printf "Add Internet traffic route through ppp0\n" sudo route add -net "0.0.0.0/0" dev "ppp0" printf "Netstat output of all PPTP sockets\n" netstat -a | grep "/var/run/pptp/" fi
其它vpn="on" 是開機會執行 如不想執行可以設定off
設定完成可以執行測試是否能正常執行
sudo /etc/rc.local
參考資料:http://devtidbits.com/2013/02/19/using-a-point-to-point-tunnelling-protocol-virtual-private-network-pptp-vpn-client-on-a-raspberry-pi/