vpn.sh 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. #!/bin/bash
  2. red='\e[1;31m'
  3. green='\e[0;32m'
  4. NC='\e[0m'
  5. MYIP=$(wget -qO- ipinfo.io/ip);
  6. IZIN=$( curl https://raw.githubusercontent.com/alifnurmareta/premium/main/iptext.sh | grep $MYIP )
  7. if [ $MYIP = $IZIN ]; then
  8. clear
  9. echo -e "${green} Please Wait, Proses...${NC}"
  10. sleep 5
  11. else
  12. echo "User premium Only ,Sila Contact Admin Bot😘"
  13. exit 0
  14. fi
  15. clear
  16. # initialisasi var
  17. export DEBIAN_FRONTEND=noninteractive
  18. OS=`uname -m`;
  19. MYIP=$(wget -qO- ipinfo.io/ip);
  20. MYIP2="s/xxxxxxxxx/$MYIP/g";
  21. ANU=$(ip -o $ANU -4 route show to default | awk '{print $5}');
  22. domain=$(cat /etc/v2ray/domain)
  23. # Install OpenVPN dan Easy-RSA
  24. apt install openvpn easy-rsa unzip -y
  25. apt install openssl iptables iptables-persistent -y
  26. mkdir -p /etc/openvpn/server/easy-rsa/
  27. cd /etc/openvpn/
  28. wget https://raw.githubusercontent.com/alifnurmareta/bc/main/vpn.zip
  29. unzip vpn.zip
  30. rm -f vpn.zip
  31. chown -R root:root /etc/openvpn/server/easy-rsa/
  32. cd
  33. mkdir -p /usr/lib/openvpn/
  34. cp /usr/lib/x86_64-linux-gnu/openvpn/plugins/openvpn-plugin-auth-pam.so /usr/lib/openvpn/openvpn-plugin-auth-pam.so
  35. # nano /etc/default/openvpn
  36. sed -i 's/#AUTOSTART="all"/AUTOSTART="all"/g' /etc/default/openvpn
  37. # restart openvpn dan status openvpn
  38. systemctl enable --now openvpn-server@server-tcp-1194
  39. systemctl enable --now openvpn-server@server-udp-2200
  40. /etc/init.d/openvpn restart
  41. /etc/init.d/openvpn status
  42. # aktifkan ip4 forwarding
  43. echo 1 > /proc/sys/net/ipv4/ip_forward
  44. sed -i 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/g' /etc/sysctl.conf
  45. # Buat config client TCP 1194
  46. cat > /etc/openvpn/client-tcp-1194.ovpn <<-END
  47. setenv FRIENDLY_NAME ""
  48. client
  49. dev tun
  50. proto tcp
  51. remote ${domain} 1194
  52. http-proxy ${domain} 8080
  53. http-proxy-option CUSTOM-HEADER X-Forwarded-Host ""
  54. resolv-retry infinite
  55. route-method exe
  56. nobind
  57. persist-key
  58. persist-tun
  59. auth-user-pass
  60. comp-lzo
  61. verb 3
  62. END
  63. sed -i $MYIP2 /etc/openvpn/client-tcp-1194.ovpn;
  64. # Buat config client UDP 2200
  65. cat > /etc/openvpn/client-udp-2200.ovpn <<-END
  66. setenv FRIENDLY_NAME ""
  67. client
  68. dev tun
  69. proto udp
  70. remote xxxxxxxxx 2200
  71. resolv-retry infinite
  72. route-method exe
  73. nobind
  74. persist-key
  75. persist-tun
  76. auth-user-pass
  77. comp-lzo
  78. verb 3
  79. END
  80. sed -i $MYIP2 /etc/openvpn/client-udp-2200.ovpn;
  81. # Buat config client SSL
  82. cat > /etc/openvpn/client-tcp-ssl.ovpn <<-END
  83. setenv FRIENDLY_NAME ""
  84. client
  85. dev tun
  86. proto tcp
  87. remote xxxxxxxxx 442
  88. resolv-retry infinite
  89. route-method exe
  90. nobind
  91. persist-key
  92. persist-tun
  93. auth-user-pass
  94. comp-lzo
  95. verb 3
  96. END
  97. sed -i $MYIP2 /etc/openvpn/client-tcp-ssl.ovpn;
  98. cd
  99. # pada tulisan xxx ganti dengan alamat ip address VPS anda
  100. /etc/init.d/openvpn restart
  101. # masukkan certificatenya ke dalam config client TCP 1194
  102. echo '<ca>' >> /etc/openvpn/client-tcp-1194.ovpn
  103. cat /etc/openvpn/server/ca.crt >> /etc/openvpn/client-tcp-1194.ovpn
  104. echo '</ca>' >> /etc/openvpn/client-tcp-1194.ovpn
  105. # Copy config OpenVPN client ke home directory root agar mudah didownload ( TCP 1194 )
  106. cp /etc/openvpn/client-tcp-1194.ovpn /home/vps/public_html/client-tcp-1194.ovpn
  107. # masukkan certificatenya ke dalam config client UDP 2200
  108. echo '<ca>' >> /etc/openvpn/client-udp-2200.ovpn
  109. cat /etc/openvpn/server/ca.crt >> /etc/openvpn/client-udp-2200.ovpn
  110. echo '</ca>' >> /etc/openvpn/client-udp-2200.ovpn
  111. # Copy config OpenVPN client ke home directory root agar mudah didownload ( UDP 2200 )
  112. cp /etc/openvpn/client-udp-2200.ovpn /home/vps/public_html/client-udp-2200.ovpn
  113. # masukkan certificatenya ke dalam config client SSL
  114. echo '<ca>' >> /etc/openvpn/client-tcp-ssl.ovpn
  115. cat /etc/openvpn/server/ca.crt >> /etc/openvpn/client-tcp-ssl.ovpn
  116. echo '</ca>' >> /etc/openvpn/client-tcp-ssl.ovpn
  117. # Copy config OpenVPN client ke home directory root agar mudah didownload ( SSL )
  118. cp /etc/openvpn/client-tcp-ssl.ovpn /home/vps/public_html/client-tcp-ssl.ovpn
  119. #firewall untuk memperbolehkan akses UDP dan akses jalur TCP
  120. iptables -t nat -I POSTROUTING -s 10.6.0.0/24 -o $ANU -j MASQUERADE
  121. iptables -t nat -I POSTROUTING -s 10.7.0.0/24 -o $ANU -j MASQUERADE
  122. iptables-save > /etc/iptables.up.rules
  123. chmod +x /etc/iptables.up.rules
  124. iptables-restore -t < /etc/iptables.up.rules
  125. netfilter-persistent save
  126. netfilter-persistent reload
  127. # Restart service openvpn
  128. systemctl enable openvpn
  129. systemctl start openvpn
  130. /etc/init.d/openvpn restart
  131. # Delete script
  132. history -c
  133. rm -f /root/vpn.sh