------------------------------------------------------------------------------------------------

Option 1. With DHCP for receiving routes

------------------------------------------------------------------------------------------------

1. Update
sudo apt-get update -y

2. Install pptp-linux
sudo apt-get install -y pptp-linux

3. Create connection
sudo pptpsetup --create vpnki --server msk.vpnki.ru --username <tunnel name> --password <tunnel password>

4. Connect tunnel
sudo pon vpnki updetach

5. Check interface ppp0
ifconfig -s

6. Ping VPNKI router
ping 172.16.0.1

7. Disconnect tunnel
sudo poff vpnki

8. Check interface ppp0
ifconfig -s

9. Add automatic set-up PPTP tunnel on OS boot, open file
sudo nano -B /etc/rc.local

10. Before "exit 0" input this text


vpn="on"
if [ $vpn = on ]; then
printf "\nVPN connection to VPNKI\n"
pon vpnki updetach
printf "Netstat output of all PPTP sockets\n"
netstat -a | grep "/var/run/pptp/"
fi


Save Ctrl+X

11. Test local.rc without reboot
sudo /etc/rc.local

12. Check interface ppp0
ifconfig -s

13. We need to auto-reconnect feature activate in case of line disconnect. For this open file

sudo nano -B /etc/ppp/peers/vpnki

14. Please add in the end of file

persist
maxfail 0
holdoff 10

Save Ctrl+X

15. For receiving routes from VPNKI network and routes from your other tunnels (DHCP Option 249) you have to download, extract and put this fileе (named splitp) in /etc/ppp/ip-up.d

16. Please change rights to run this file

chmod 755 /etc/ppp/ip-up.d/splitp

 

-----------------------------------------------------------------------

Option 2. With static routes

-----------------------------------------------------------------------

1. Update
sudo apt-get update -y
sudo apt-get upgrade -y

2. Install pptp-linux
sudo apt-get install -y pptp-linux

3. Create connection
sudo pptpsetup --create vpnki --server msk.vpnki.ru --username <tunnel name> --password <tunnel password>

4. Connect tunnel
sudo pon vpnki updetach

5. Check that  ppp0 is up
ifconfig -s

6. Pingа VPNKI router
ping 172.16.0.1

7. Disconnect tunnel
sudo poff vpnki

8. Check ppp0 disconnect
ifconfig -s

9. Add automatic PPTP connect on OS boot, open file
sudo nano -B /etc/rc.local

10. Just before "exit 0"  add text


vpn="on"
if [ $vpn = on ]; then
printf "\nVPN connection to VPNKI\n"
pon vpnki updetach
sudo route add -net "172.16.0.0/16" dev "ppp0"    #Route to VPNKI network
sudo route add -net "192.168.100.0/24" dev "ppp0"  #Example route to your "other" tunnel (in home network 192.168.100.0/24)
printf "Netstat output of all PPTP sockets\n"
netstat -a | grep "/var/run/pptp/"
fi


Save Ctrl+X

11. Test local.rc without reboot
sudo /etc/rc.local

12. Check ppp0 interface
ifconfig -s

13. We have to enable auto reconnect feature in case of line disconnect, please open file

sudo nano -B /etc/ppp/peers/vpnki

14. Add at the end

 

persist
maxfail 0
holdoff 10

 

Save Ctrl+X

15. We have to automatically put routes to VPNKI network (and your "other" tunnel) in case of line disconnect. Please create file

sudo nano -B /etc/ppp/ip-up.d/routeadd

16. And add this lines to file:

 

#!/bin/sh -e
route add -net "172.16.0.0/16" dev "ppp0" #Route to VPNKI network
route add -net "192.168.100.0/24" dev "ppp0" #Example route to your "other" network 192.168.100.0/24

 

Save Ctrl+X

17. Please change rights to run this file when ppp0 is up

chmod 755 /etc/ppp/ip-up.d/routeadd