Guest User

Untitled

a guest
Sep 9th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. echo "Choose an action:"
  4. echo "1) Create new PoPToP VPN and create new user"
  5. echo "2) Create new user"
  6.  
  7. read x
  8.  
  9. if test $x -eq 1; then
  10. echo "Enter name for new user:"
  11.  
  12. read u
  13. echo "Enter a password:"
  14.  
  15. read p
  16. # get the VPS IP
  17. ip=`ifconfig eth0 | grep 'inet addr' | awk {'print $2'} | sed s/.*://`
  18.  
  19. echo
  20. echo "Set up PoPToP"
  21.  
  22. apt-get update
  23. apt-get install pptpd
  24.  
  25. echo
  26. echo "Create config"
  27.  
  28. cat > /etc/ppp/pptpd-options << END
  29.  
  30. name pptpd
  31. refuse-pap
  32. refuse-chap
  33. refuse-mschap
  34. require-mschap-v2
  35. require-mppe-128
  36. ms-dns 8.8.8.8
  37. ms-dns 8.8.4.4
  38. proxyarp
  39. nodefaultroute
  40. lock
  41. nobsdcomp
  42.  
  43. END
  44.  
  45. # setting up pptpd.conf
  46. echo "option /etc/ppp/pptpd-options" > /etc/pptpd.conf
  47. echo "logwtmp" >> /etc/pptpd.conf
  48. echo "localip $ip" >> /etc/pptpd.conf
  49. echo "remoteip 10.1.0.1-100" >> /etc/pptpd.conf
  50.  
  51. # adding new user
  52. echo "$u * $p *" >> /etc/ppp/chap-secrets
  53. echo
  54. echo "Add redirect IPv4 and add into autoload"
  55.  
  56. cat >> /etc/sysctl.conf << END
  57.  
  58. net.ipv4.ip_forward=1
  59.  
  60. END
  61.  
  62. sysctl -p
  63.  
  64. echo
  65. echo "Update IPtables Routing and add into autoload"
  66.  
  67. iptables -t nat -A POSTROUTING -j SNAT --to $ip
  68. # saves iptables routing rules and enables them on-boot
  69. iptables-save > /etc/iptables.conf
  70. cat > /etc/network/if-pre-up.d/iptables << END
  71.  
  72. #!/bin/sh
  73. iptables-restore < /etc/iptables.conf
  74.  
  75. END
  76.  
  77. chmod +x /etc/network/if-pre-up.d/iptables
  78. cat >> /etc/ppp/ip-up << END
  79.  
  80. ifconfig ppp0 mtu 1400
  81.  
  82. END
  83.  
  84. echo
  85. echo "Restart PoPToP"
  86.  
  87. /etc/init.d/pptpd restart
  88.  
  89. echo
  90. echo "Installation is finished"
  91. echo "Your IP: $ip? login and password:"
  92. echo "Login:$u ##### Password: $p"
  93.  
  94. # runs this if option 2 is selected
  95. elif test $x -eq 2; then
  96. echo "Enter name for new user:"
  97. read u
  98. echo "Enter a password:"
  99. read p
  100.  
  101. # get the VPS IP
  102. ip=`ifconfig venet0:0 | grep 'inet addr' | awk {'print $2'} | sed s/.*://`
  103. # adding new user
  104.  
  105. echo "$u * $p *" >> /etc/ppp/chap-secrets
  106. echo
  107. echo "New user is created"
  108. echo "Server IP: $ip, credential:"
  109. echo "Login:$u ##### Password: $p"
  110.  
  111. else
  112. echo "Wrong option, pleas try one more..."
  113. exit
  114. fi
Add Comment
Please, Sign In to add comment