Advertisement
Guest User

Untitled

a guest
Apr 1st, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.73 KB | None | 0 0
  1. #!/bin/bash
  2. # Interactive PoPToP install script for an KVM VPS
  3. # Tested on Debian 7, and Ubuntu 12.04-15.04
  4. # Feb 14, 2016 v1.
  5.  
  6. echo "######################################################"
  7. echo "Interactive PoPToP Install Script for an KVM VPS"
  8. echo
  9. echo "Make sure to contact your provider and have them enable"
  10. echo "IPtables and ppp modules prior to setting up PoPToP."
  11. echo "PPP can also be enabled from SolusVM."
  12. echo
  13. echo "You need to set up the server before creating more users."
  14. echo "A separate user is required per connection or machine."
  15. echo "######################################################"
  16. echo
  17. echo
  18. echo "######################################################"
  19. echo "Select on option:"
  20. echo "1) Set up new PoPToP server AND create one user"
  21. echo "2) Create additional users"
  22. echo "######################################################"
  23. read x
  24. if test $x -eq 1; then
  25. echo "Enter username that you want to create (eg. client1 or john):"
  26. read u
  27. echo "Specify password that you want the server to use:"
  28. read p
  29.  
  30. # get the VPS IP
  31. ip=`ifconfig eth0 | grep 'inet addr' | awk {'print $2'} | sed s/.*://`
  32.  
  33. echo
  34. echo "######################################################"
  35. echo "Downloading and Installing PoPToP"
  36. echo "######################################################"
  37. apt-get update
  38. apt-get -y install pptpd
  39.  
  40. echo
  41. echo "######################################################"
  42. echo "Creating Server Config"
  43. echo "######################################################"
  44. cat > /etc/ppp/pptpd-options <<END
  45. name pptpd
  46. refuse-pap
  47. refuse-chap
  48. refuse-mschap
  49. require-mschap-v2
  50. require-mppe-128
  51. ms-dns 8.8.8.8
  52. ms-dns 8.8.4.4
  53. proxyarp
  54. nodefaultroute
  55. lock
  56. nobsdcomp
  57. END
  58.  
  59. # setting up pptpd.conf
  60. echo "option /etc/ppp/pptpd-options" > /etc/pptpd.conf
  61. echo "logwtmp" >> /etc/pptpd.conf
  62. echo "localip $ip" >> /etc/pptpd.conf
  63. echo "remoteip 10.1.0.1-100" >> /etc/pptpd.conf
  64.  
  65. # adding new user
  66. echo "$u * $p *" >> /etc/ppp/chap-secrets
  67.  
  68. echo
  69. echo "######################################################"
  70. echo "Forwarding IPv4 and Enabling it on boot"
  71. echo "######################################################"
  72. cat >> /etc/sysctl.conf <<END
  73. net.ipv4.ip_forward=1
  74. END
  75. sysctl -p
  76.  
  77. echo
  78. echo "######################################################"
  79. echo "Updating IPtables Routing and Enabling it on boot"
  80. echo "######################################################"
  81. iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
  82. # saves iptables routing rules and enables them on-boot
  83. iptables-save > /etc/iptables.conf
  84.  
  85. cat > /etc/network/if-pre-up.d/iptables <<END
  86. #!/bin/sh
  87. iptables-restore < /etc/iptables.conf
  88. END
  89.  
  90. chmod +x /etc/network/if-pre-up.d/iptables
  91. cat >> /etc/ppp/ip-up <<END
  92. ifconfig ppp0 mtu 1400
  93. END
  94.  
  95. echo
  96. echo "######################################################"
  97. echo "Restarting PoPToP"
  98. echo "######################################################"
  99. sleep 5
  100. /etc/init.d/pptpd restart
  101.  
  102. echo
  103. echo "######################################################"
  104. echo "Server setup complete!"
  105. echo "Connect to your VPS at $ip with these credentials:"
  106. echo "Username:$u ##### Password: $p"
  107. echo "######################################################"
  108.  
  109. # runs this if option 2 is selected
  110. elif test $x -eq 2; then
  111. echo "Enter username that you want to create (eg. client1 or john):"
  112. read u
  113. echo "Specify password that you want the server to use:"
  114. read p
  115.  
  116. # get the VPS IP
  117. ip=`ifconfig eth0 | grep 'inet addr' | awk {'print $2'} | sed s/.*://`
  118.  
  119. # adding new user
  120. echo "$u * $p *" >> /etc/ppp/chap-secrets
  121.  
  122. echo
  123. echo "######################################################"
  124. echo "Addtional user added!"
  125. echo "Connect to your VPS at $ip with these credentials:"
  126. echo "Username:$u ##### Password: $p"
  127. echo "######################################################"
  128.  
  129. else
  130. echo "Invalid selection, quitting."
  131. exit
  132. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement