Guest User

Untitled

a guest
Aug 18th, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.62 KB | None | 0 0
  1. # Requirements
  2. # debian/ubuntu
  3.  
  4. apt-get -y update && apt-get -y upgrade
  5. apt-get -y install strongswan xl2tpd libstrongswan-standard-plugins libstrongswan-extra-plugins
  6.  
  7. VPN_SERVER_IP=''
  8. VPN_IPSEC_PSK='y'
  9. VPN_USER=''
  10. VPN_PASSWORD=''
  11.  
  12. cat > /etc/ipsec.conf <<EOF
  13. config setup
  14. conn %default
  15. ikelifetime=60m
  16. keylife=20m
  17. rekeymargin=3m
  18. keyingtries=1
  19. keyexchange=ikev1
  20. authby=secret
  21.  
  22. conn VPN1
  23. keyexchange=ikev1
  24. left=%defaultroute
  25. auto=add
  26. authby=secret
  27. type=transport
  28. leftprotoport=17/1701
  29. rightprotoport=17/1701
  30. right=$VPN_SERVER_IP
  31. EOF
  32.  
  33. cat > /etc/ipsec.secrets <<EOF
  34. : PSK "$VPN_IPSEC_PSK"
  35. EOF
  36.  
  37. chmod 600 /etc/ipsec.secrets
  38.  
  39. cat > /etc/xl2tpd/xl2tpd.conf <<EOF
  40. [lac VPN1]
  41. lns = $VPN_SERVER_IP
  42. ppp debug = yes
  43. pppoptfile = /etc/ppp/options.l2tpd.client
  44. length bit = yes
  45. EOF
  46.  
  47. cat > /etc/ppp/options.l2tpd.client <<EOF
  48. ipcp-accept-local
  49. ipcp-accept-remote
  50. refuse-eap
  51. require-chap
  52. noccp
  53. noauth
  54. mtu 1280
  55. mru 1280
  56. noipdefault
  57. defaultroute
  58. usepeerdns
  59. connect-delay 5000
  60. name $VPN_USER
  61. password $VPN_PASSWORD
  62. EOF
  63.  
  64. chmod 600 /etc/ppp/options.l2tpd.client
  65.  
  66. service strongswan restart
  67. service xl2tpd restart
  68.  
  69. cat > /usr/local/bin/start-vpn <<EOF
  70. #!/bin/bash
  71.  
  72. (service strongswan start ;
  73. sleep 2 ;
  74. service xl2tpd start) && (
  75.  
  76. ipsec up VPN1
  77. echo "c VPN1" > /var/run/xl2tpd/l2tp-control
  78. sleep 5
  79. #ip route add 10.0.0.0/24 dev ppp0
  80. )
  81. EOF
  82. chmod +x /usr/local/bin/start-vpn
  83.  
  84. cat > /usr/local/bin/stop-vpn <<EOF
  85. #!/bin/bash
  86.  
  87. (echo "d myvpn" > /var/run/xl2tpd/l2tp-control
  88. ipsec down myvpn) && (
  89. service xl2tpd stop ;
  90. service stringswan stop)
  91. EOF
  92. chmod +x /usr/local/bin/stop-vpn
  93.  
  94. echo "To start VPN type: start-vpn"
  95. echo "To stop VPN type: stop-vpn"
Add Comment
Please, Sign In to add comment