Advertisement
Guest User

Untitled

a guest
Feb 1st, 2017
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. #!/bin/bash
  2. # Digital Ocean
  3. # Ubuntu 12.04 x64 Server
  4. # Open VPN
  5. echo "Select on option:"
  6. echo "1) Set up new PoPToP server AND create one user"
  7. echo "2) Create additional users"
  8. read x
  9. if test $x -eq 1; then
  10. echo "Enter username that you want to create (eg. client1 or john):"
  11. read u
  12. echo "Specify password that you want the server to use:"
  13. read p
  14.  
  15. # get the VPS IP
  16. ip=`ifconfig eth0 | grep 'inet addr' | awk {'print $2'} | sed s/.*://`
  17.  
  18. echo
  19. echo "Downloading and Installing PoPToP"
  20. apt-get update
  21. apt-get install pptpd
  22.  
  23. echo
  24. echo "Creating Server Config"
  25. cat > /etc/ppp/pptpd-options <<END
  26. name pptpd
  27. refuse-pap
  28. refuse-chap
  29. refuse-mschap
  30. require-mschap-v2
  31. require-mppe-128
  32. ms-dns 8.8.8.8
  33. ms-dns 8.8.4.4
  34. proxyarp
  35. nodefaultroute
  36. lock
  37. nobsdcomp
  38. END
  39.  
  40. # setting up pptpd.conf
  41. echo "option /etc/ppp/pptpd-options" > /etc/pptpd.conf
  42. echo "logwtmp" >> /etc/pptpd.conf
  43. echo "localip $ip" >> /etc/pptpd.conf
  44. echo "remoteip 10.1.0.1-100" >> /etc/pptpd.conf
  45.  
  46. # adding new user
  47. echo "$u * $p *" >> /etc/ppp/chap-secrets
  48.  
  49. echo
  50. echo "Forwarding IPv4 and Enabling it on boot"
  51. cat >> /etc/sysctl.conf <<END
  52. net.ipv4.ip_forward=1
  53. END
  54. sysctl -p
  55.  
  56. echo
  57. echo "Updating IPtables Routing and Enabling it on boot"
  58. iptables -t nat -A POSTROUTING -j SNAT --to $ip
  59. # saves iptables routing rules and enables them on-boot
  60. iptables-save > /etc/iptables.conf
  61.  
  62. cat > /etc/network/if-pre-up.d/iptables <<END
  63. #!/bin/sh
  64. iptables-restore < /etc/iptables.conf
  65. END
  66.  
  67. chmod +x /etc/network/if-pre-up.d/iptables
  68. cat >> /etc/ppp/ip-up <<END
  69. ifconfig ppp0 mtu 1400
  70. END
  71.  
  72. echo
  73. echo "Restarting PoPToP"
  74. /etc/init.d/pptpd restart
  75.  
  76. echo
  77. echo "Server setup complete!"
  78. echo "Connect to your VPS at $ip with these credentials:"
  79. echo "Username:$u ##### Password: $p"
  80.  
  81. # runs this if option 2 is selected
  82. elif test $x -eq 2; then
  83. echo "Enter username that you want to create (eg. client1 or john):"
  84. read u
  85. echo "Specify password that you want the server to use:"
  86. read p
  87.  
  88. # get the VPS IP
  89. ip=`ifconfig venet0:0 | grep 'inet addr' | awk {'print $2'} | sed s/.*://`
  90.  
  91. # adding new user
  92. echo "$u * $p *" >> /etc/ppp/chap-secrets
  93.  
  94. echo
  95. echo "Addtional user added!"
  96. echo "Connect to your VPS at $ip with these credentials:"
  97. echo "Username:$u ##### Password: $p"
  98.  
  99. else
  100. echo "Invalid selection, quitting."
  101. exit
  102. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement