Guest User

Untitled

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