vpn.sh 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446
  1. #!/bin/bash
  2. #
  3. # Mod by t.me/PrinceNewbie
  4. # COPYRIGHT.2022
  5. # ==================================================
  6. # initialisasi var
  7. export DEBIAN_FRONTEND=noninteractive
  8. OS=`uname -m`;
  9. MYIP=$(wget -qO- icanhazip.com);
  10. MYIP2="s/xxxxxxxxx/$MYIP/g";
  11. ANU=$(ip -o $ANU -4 route show to default | awk '{print $5}');
  12. MySentev="$(cat /etc/v2ray/domain)";
  13. # Install OpenVPN dan Easy-RSA
  14. apt-get install -y openvpn dnsutils easy-rsa unzip
  15. apt install -y openvpn dnsutils easy-rsa unzip
  16. apt-get install -y openssl iptables iptables-persistent
  17. apt install -y openssl iptables iptables-persistent
  18. #mkdir -p /etc/openvpn/easy-rsa
  19. cd /etc/openvpn
  20. #wget https://raw.githubusercontent.com/syapik96/aws/main/install/vpn.zip
  21. wget https://notabug.org/irwanmohi/test/raw/master/vpn.zip
  22. unzip /etc/openvpn/vpn.zip
  23. rm -f /etc/openvpn/vpn.zip
  24. chown -R root:root /etc/openvpn/server
  25. # server config
  26. cp /etc/openvpn/server/ca.crt /etc/openvpn/ca.crt
  27. cp /etc/openvpn/server/easy-rsa/server/dh2048.pem /etc/openvpn/dh2048.pem
  28. cp /etc/openvpn/server/server.crt /etc/openvpn/server.crt
  29. cp /etc/openvpn/server/server.key /etc/openvpn/server.key
  30. chmod +x /etc/openvpn/ca.crt
  31. # move server config setup n tcp-udp conf
  32. #mv /etc/openvpn/server/server-tcp-1194.conf /etc/openvpn/
  33. #mv /etc/openvpn/server/server-udp-2200.conf /etc/openvpn/
  34. #mv /etc/openvpn/server/server/ipp.txt /etc/openvpn/
  35. #mv /etc/openvpn/server/server/openvpn-status.log /etc/openvpn/
  36. cat <<'EOF7'> /etc/openvpn/ca.crt
  37. -----BEGIN CERTIFICATE-----
  38. MIIFDDCCA/SgAwIBAgIJAIxbDcvh6vPEMA0GCSqGSIb3DQEBCwUAMIG0MQswCQYD
  39. VQQGEwJQSDEPMA0GA1UECBMGVGFybGFjMRMwEQYDVQQHEwpDb25jZXBjaW9uMRMw
  40. EQYDVQQKEwpKb2huRm9yZFRWMRMwEQYDVQQLEwpKb2huRm9yZFRWMRIwEAYDVQQD
  41. EwlEZWJpYW5WUE4xHTAbBgNVBCkTFEpvaG4gRm9yZCBNYW5naWxpbWFuMSIwIAYJ
  42. KoZIhvcNAQkBFhNhZG1pbkBqb2huZm9yZHR2Lm1lMB4XDTE5MTEyNTA4MDUzMFoX
  43. DTI5MTEyMjA4MDUzMFowgbQxCzAJBgNVBAYTAlBIMQ8wDQYDVQQIEwZUYXJsYWMx
  44. EzARBgNVBAcTCkNvbmNlcGNpb24xEzARBgNVBAoTCkpvaG5Gb3JkVFYxEzARBgNV
  45. BAsTCkpvaG5Gb3JkVFYxEjAQBgNVBAMTCURlYmlhblZQTjEdMBsGA1UEKRMUSm9o
  46. biBGb3JkIE1hbmdpbGltYW4xIjAgBgkqhkiG9w0BCQEWE2FkbWluQGpvaG5mb3Jk
  47. dHYubWUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCf+WkN868YMiCl
  48. d3z1Tq2OeRNb6ljiRGzEi1qrIvj/gXq6o0QD0SD+Nf3QWJrrJYFi1GECq72PNFhy
  49. 2jLFgZH0RRLOVZfG+jwZ9itxofweiwALvgMdz2e+mpQItMxKh1ZYkzNw+4zJ7zJV
  50. u0Tq7YGPaMFPkLNU3V454rDYCdI8GG/wPDoW5FMc3FogI8fwylQvTWyE0yxHMxH6
  51. FkISA5hOuSo6MO1FgAfDdNNwxa/MAbpHwJ+W6RBHv4lhE6bQePMCj/90pgt3NpxF
  52. i++qwpSRfOR6OuuyDr1c++z6qhjLB7YzDLzj+HXCyfsPWPj+gJ0+3ckhW4gf/nhR
  53. uB+BTd8fAgMBAAGjggEdMIIBGTAdBgNVHQ4EFgQULXGeDQBLXCPId0F3r/58FDCm
  54. jC4wgekGA1UdIwSB4TCB3oAULXGeDQBLXCPId0F3r/58FDCmjC6hgbqkgbcwgbQx
  55. CzAJBgNVBAYTAlBIMQ8wDQYDVQQIEwZUYXJsYWMxEzARBgNVBAcTCkNvbmNlcGNp
  56. b24xEzARBgNVBAoTCkpvaG5Gb3JkVFYxEzARBgNVBAsTCkpvaG5Gb3JkVFYxEjAQ
  57. BgNVBAMTCURlYmlhblZQTjEdMBsGA1UEKRMUSm9obiBGb3JkIE1hbmdpbGltYW4x
  58. IjAgBgkqhkiG9w0BCQEWE2FkbWluQGpvaG5mb3JkdHYubWWCCQCMWw3L4erzxDAM
  59. BgNVHRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQBZUpwZ+LQWAQI8VW3hdZVN
  60. WV+P12yYQ1UzyagtB3MqBR4aZhjk42NFBrwPZwpvWUXB0GB4DhBuvbVPtqnt5p4V
  61. sDtQ6vKYeDlE/KDGDc0oJDsgxo2wwIXy+y/14EDqidAVjtf1rk5MDAAEVvonHxkP
  62. 861kzoIOZ0+D7sJDo3aZ8uNy8UznrRSzLDT63o28DkL3iLASyt1GHWu05wYmgzsg
  63. m+w+AWvN5rL65mzyn/Bipf0I9snVB4saCgfy7TCI/4slOcMCNc2e6oOwOLvFA+s8
  64. dZMt2qg62PEOj/LblYGD+qLn0xLRwqK0UWSmWobz5LXoxyssZLK2KiMkS41PHkfh
  65. -----END CERTIFICATE-----
  66. EOF7
  67. cat <<'EOF9'> /etc/openvpn/server.crt
  68. Certificate:
  69. Data:
  70. Version: 3 (0x2)
  71. Serial Number:
  72. 53:9b:68:c4:0e:e6:31:cb:14:ea:fc:91:ec:f5:b0:b8
  73. Signature Algorithm: sha256WithRSAEncryption
  74. Issuer: CN=Aidan VPN
  75. Validity
  76. Not Before: Mar 13 13:26:48 2022 GMT
  77. Not After : Mar 10 13:26:48 2032 GMT
  78. Subject: CN=server
  79. Subject Public Key Info:
  80. Public Key Algorithm: rsaEncryption
  81. RSA Public-Key: (2048 bit)
  82. Modulus:
  83. 00:bf:27:07:c2:a9:b3:04:41:98:c3:0e:17:c5:7c:
  84. 78:c0:d5:c1:33:2f:6b:07:1b:da:49:86:a6:a1:1f:
  85. 10:de:bb:f6:98:08:88:49:21:fd:19:f7:87:d2:5f:
  86. 5e:23:54:2b:02:fd:8b:8c:bc:88:f5:6f:53:2b:da:
  87. 9f:93:0d:f3:6c:3f:6f:3e:e0:40:32:56:96:4a:a4:
  88. 11:1d:29:bd:78:b1:16:71:fb:c5:8f:1a:c5:cf:68:
  89. 73:49:a2:13:39:9f:06:92:62:38:dc:ee:32:43:7e:
  90. 0e:19:98:a1:50:4a:1f:1d:5b:b8:cd:b6:a3:b7:aa:
  91. 85:35:f4:2e:15:7d:de:16:a2:f6:45:64:99:67:c3:
  92. c5:0f:a9:8d:50:c6:e7:25:08:18:fd:75:c0:a1:0d:
  93. 93:db:c7:77:44:54:ae:43:7f:3e:ee:94:11:09:fb:
  94. c4:5a:33:ab:1f:40:35:2a:9a:1b:46:f4:49:4d:9d:
  95. 33:6c:67:0b:d0:41:4b:4d:a1:17:47:05:4d:9b:88:
  96. 99:9a:64:93:3b:25:80:06:22:d9:f1:fc:69:fc:3c:
  97. 05:61:b6:31:7f:f8:42:3f:ff:8c:84:d2:60:17:8c:
  98. bd:ba:49:cc:83:6c:b2:a5:8e:d9:b7:57:b1:9b:e7:
  99. 7f:e4:f9:c8:01:06:98:ea:63:19:e3:37:7d:af:c8:
  100. f1:5b
  101. Exponent: 65537 (0x10001)
  102. X509v3 extensions:
  103. X509v3 Basic Constraints:
  104. CA:FALSE
  105. X509v3 Subject Key Identifier:
  106. F2:16:9F:93:AB:FD:DB:F2:B4:68:FD:B9:E8:B1:35:4E:C3:CA:25:CF
  107. X509v3 Authority Key Identifier:
  108. keyid:24:84:8C:FD:34:DA:30:CD:54:24:4A:21:A2:D0:BC:4B:4C:C1:1C:41
  109. DirName:/CN=Aidan VPN
  110. serial:12:7D:57:E2:8E:64:E5:AA:EC:C7:B3:8E:31:EC:06:19:C9:CF:A7:B6
  111. X509v3 Extended Key Usage:
  112. TLS Web Server Authentication
  113. X509v3 Key Usage:
  114. Digital Signature, Key Encipherment
  115. X509v3 Subject Alternative Name:
  116. DNS:server
  117. Signature Algorithm: sha256WithRSAEncryption
  118. c4:55:3b:7f:d5:d1:55:bc:74:31:d0:c8:8d:74:8a:d5:0e:0f:
  119. 37:82:3b:59:ad:32:f5:89:e8:03:e5:8d:dc:c0:3b:4e:36:a9:
  120. 61:85:22:72:66:c3:d6:fc:18:a5:5c:b5:8f:ee:a9:10:0f:de:
  121. 78:82:0e:41:87:94:3f:29:fb:e8:32:23:31:c6:c4:48:1e:68:
  122. b4:15:b7:a1:99:60:e1:93:01:b2:fa:72:84:85:23:fe:ab:79:
  123. bb:3e:d3:07:10:a5:60:e2:4f:35:f5:98:45:34:43:f3:99:14:
  124. 33:1c:f3:4c:65:59:0d:a0:6c:97:88:cb:6d:b2:73:80:27:0d:
  125. f3:96:8a:7b:18:a3:7d:9a:c7:29:17:c3:e5:7a:95:18:a5:b4:
  126. 5b:cf:7d:d6:b4:0a:5f:7f:ac:b1:2c:23:2a:7a:82:bc:c3:28:
  127. f4:db:15:15:00:49:76:3c:d7:d5:ed:35:b2:ee:94:f3:ce:ad:
  128. ab:16:c6:e9:0f:f4:f4:81:13:23:a7:00:dd:1e:26:48:4b:0f:
  129. 22:1d:1f:b1:25:82:e9:5f:33:ae:59:70:b0:79:a4:d4:bd:08:
  130. d5:0d:a2:2a:a1:a8:ce:e5:10:40:02:9f:19:22:97:30:64:cb:
  131. 23:5e:06:e5:fd:d8:de:99:28:34:24:05:10:c7:d0:27:63:51:
  132. df:ca:f2:f2
  133. -----BEGIN CERTIFICATE-----
  134. MIIDYzCCAkugAwIBAgIQU5toxA7mMcsU6vyR7PWwuDANBgkqhkiG9w0BAQsFADAU
  135. MRIwEAYDVQQDDAlBaWRhbiBWUE4wHhcNMjIwMzEzMTMyNjQ4WhcNMzIwMzEwMTMy
  136. NjQ4WjARMQ8wDQYDVQQDDAZzZXJ2ZXIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
  137. ggEKAoIBAQC/JwfCqbMEQZjDDhfFfHjA1cEzL2sHG9pJhqahHxDeu/aYCIhJIf0Z
  138. 94fSX14jVCsC/YuMvIj1b1Mr2p+TDfNsP28+4EAyVpZKpBEdKb14sRZx+8WPGsXP
  139. aHNJohM5nwaSYjjc7jJDfg4ZmKFQSh8dW7jNtqO3qoU19C4Vfd4WovZFZJlnw8UP
  140. qY1QxuclCBj9dcChDZPbx3dEVK5Dfz7ulBEJ+8RaM6sfQDUqmhtG9ElNnTNsZwvQ
  141. QUtNoRdHBU2biJmaZJM7JYAGItnx/Gn8PAVhtjF/+EI//4yE0mAXjL26ScyDbLKl
  142. jtm3V7Gb53/k+cgBBpjqYxnjN32vyPFbAgMBAAGjgbMwgbAwCQYDVR0TBAIwADAd
  143. BgNVHQ4EFgQU8hafk6v92/K0aP256LE1TsPKJc8wTwYDVR0jBEgwRoAUJISM/TTa
  144. MM1UJEohotC8S0zBHEGhGKQWMBQxEjAQBgNVBAMMCUFpZGFuIFZQToIUEn1X4o5k
  145. 5arsx7OOMewGGcnPp7YwEwYDVR0lBAwwCgYIKwYBBQUHAwEwCwYDVR0PBAQDAgWg
  146. MBEGA1UdEQQKMAiCBnNlcnZlcjANBgkqhkiG9w0BAQsFAAOCAQEAxFU7f9XRVbx0
  147. MdDIjXSK1Q4PN4I7Wa0y9YnoA+WN3MA7TjapYYUicmbD1vwYpVy1j+6pEA/eeIIO
  148. QYeUPyn76DIjMcbESB5otBW3oZlg4ZMBsvpyhIUj/qt5uz7TBxClYOJPNfWYRTRD
  149. 85kUMxzzTGVZDaBsl4jLbbJzgCcN85aKexijfZrHKRfD5XqVGKW0W8991rQKX3+s
  150. sSwjKnqCvMMo9NsVFQBJdjzX1e01su6U886tqxbG6Q/09IETI6cA3R4mSEsPIh0f
  151. sSWC6V8zrllwsHmk1L0I1Q2iKqGozuUQQAKfGSKXMGTLI14G5f3Y3pkoNCQFEMfQ
  152. J2NR38ry8g==
  153. -----END CERTIFICATE-----
  154. EOF9
  155. cat <<'EOF10'> /etc/openvpn/server.key
  156. -----BEGIN PRIVATE KEY-----
  157. MIIEwAIBADANBgkqhkiG9w0BAQEFAASCBKowggSmAgEAAoIBAQC/JwfCqbMEQZjD
  158. DhfFfHjA1cEzL2sHG9pJhqahHxDeu/aYCIhJIf0Z94fSX14jVCsC/YuMvIj1b1Mr
  159. 2p+TDfNsP28+4EAyVpZKpBEdKb14sRZx+8WPGsXPaHNJohM5nwaSYjjc7jJDfg4Z
  160. mKFQSh8dW7jNtqO3qoU19C4Vfd4WovZFZJlnw8UPqY1QxuclCBj9dcChDZPbx3dE
  161. VK5Dfz7ulBEJ+8RaM6sfQDUqmhtG9ElNnTNsZwvQQUtNoRdHBU2biJmaZJM7JYAG
  162. Itnx/Gn8PAVhtjF/+EI//4yE0mAXjL26ScyDbLKljtm3V7Gb53/k+cgBBpjqYxnj
  163. N32vyPFbAgMBAAECggEBAL77uRY2RQUgoQdpojiPR3qrVu/UFaQxoORLY1qh1lIk
  164. DJoUFE61ZdM27H41CLJVmu/O8Um46UIHa1rqgPsFOkvSCU0R8zIYLur+h5bSqFrY
  165. 3CsgOV/kiPTUUDOmenzctU02U8fxOUkTvfS2+Z1loTbM+JSYQXT1K0kf4ZdZfbaw
  166. ePR6muQSXameianZLF6dqNmOHqy50eX5Cn2bDrUFZQZcC4QKajcNPSb8GbcIsMgg
  167. MAhukCWg0/++7HJYg5iSsXScAArBrBV6iNkMxoCKFztzdlE1CLfzKAZFRDH4Zsrt
  168. zBtF87LTvOniXdxd5ZYq7VpPvtvEcMwUeRYjoOvhzXECgYEA9Pf2zbvobXFXRMI+
  169. 9XjLLuGcLOGUOTFCb6hgFvfNhM8iC/LAlcmz3YLKgWAbi3CCm+7YGgiQ3ImMDdcv
  170. NV6A/71n1vT3dpqfaoCpfZrl4vorYmhuY0RLNFDy1kGXnGJl96Ppy4KKdnocqKje
  171. 8NSpbRdnJ4nJ0+HIUkq4VIng7IkCgYEAx8KqVsgnYtDUVDq+c5dgPYI0Zb1iZO4D
  172. HjhX3RYntFhnoecPhpahtvUxNNcX9i1qEoSr8TWy780AN/bziNWYzWc41FqcvWQr
  173. BuujfCrcFjlpQ/BzfQicz1evuBdmaKmMmbltP/sghEviIjxwOu1gDNkCExxANjxK
  174. BHJu+HuPXcMCgYEA1QdN+VuPpJ0L5x+E4LNK/ln0FpOU8qeDvtYNueuFLhly4jEY
  175. iSn+4IL818VcLsaIzlHGW91XHHIA+YhH5YFpbPypcKVXDi0otNVuj2xEvj4PvGRU
  176. mr6pJ7W9d9VSowxu4AwLJI9BGgbXJVS1i3lkXRoc+qU4fqm6KtYPtnSwxQECgYEA
  177. g3mOHzvxIEqN1Tosq2uQPit6TRQOtJsqljNDMRIp47rjyl2HjG+L1B0g28RN0wsk
  178. 6zdC66kKMmZcpHj25LKgtWAguTNCQiyxXQauPUUAQehbbgnOGRcYDieKUcGk93HQ
  179. RkUSsK+aQTiohxv8Sex98TbK9MT9RjT8Cl0+yHCadX0CgYEAqzh7y7JaQV5SpIS9
  180. Iu1s0TFsUyhhTVLUb9nABWVX0sfi9gf9ij/3p/V+r5P30iaRUx8d72R9tFclBKSm
  181. RhorWKhxk1ppbCRqHGuqRnCXGU0mmm9hJmllek1DSFi8NAfxuupKRvlYJJN0AG5F
  182. pyGoVzXfwFEAbFORAo9Y1cZyFNU=
  183. -----END PRIVATE KEY-----
  184. EOF10
  185. cat <<'EOF13'> /etc/openvpn/dh2048.pem
  186. -----BEGIN DH PARAMETERS-----
  187. MIIBCAKCAQEArmQMu1nrBaN7jtF4UDK9xk0T5J44pNrl4mlNHKkOjoOuAC1Jo2wF
  188. p997VJNUY99ttEEi/dZbVKFH9S007ny1xJny//bkYdJznPiTvYXdwbu/nBZPlzho
  189. n8YcbuwL54LHN+iJ6lRaaYTJumUJQhfmcfbg5CbNsnnWnMwmgtlhlF7yXPs95al6
  190. rNlUT15+80XXCR3jSPR/et7jebxNJnOxc3FcZCwRkgqxrtcYlGXMOwTJLO+AyYjQ
  191. BPpTD8iMAXYLPgahpq11/ZCVlHxi7i3Oed2YPd2TrET4Lm8Sbh33eKhxBSThooox
  192. 00Gn4IhcAamTry+6tmz4I69Q5yo1Ze1QqwIBAg==
  193. -----END DH PARAMETERS-----
  194. EOF13
  195. cd
  196. mkdir -p /usr/lib/openvpn/
  197. cp /usr/lib/x86_64-linux-gnu/openvpn/plugins/openvpn-plugin-auth-pam.so /usr/lib/openvpn/openvpn-plugin-auth-pam.so
  198. # nano /etc/default/openvpn
  199. sed -i 's/#AUTOSTART="all"/AUTOSTART="all"/g' /etc/default/openvpn
  200. # aktifkan ip4 forwarding
  201. echo 1 > /proc/sys/net/ipv4/ip_forward
  202. sed -i 's/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=1/g' /etc/sysctl.conf
  203. # Remove default Create New
  204. cd
  205. rm /etc/openvpn/*.conf
  206. # Buat config server TCP 1194
  207. cd /etc/openvpn
  208. cat > /etc/openvpn/server-tcp-1194.conf <<-EOF
  209. port 1194
  210. proto tcp
  211. dev tun
  212. ca ca.crt
  213. cert server.crt
  214. key server.key
  215. dh dh2048.pem
  216. plugin /usr/lib/openvpn/openvpn-plugin-auth-pam.so login
  217. verify-client-cert none
  218. username-as-common-name
  219. server 10.6.0.0 255.255.255.0
  220. ifconfig-pool-persist ipp.txt
  221. push "redirect-gateway def1 bypass-dhcp"
  222. push "dhcp-option DNS 1.1.1.1"
  223. push "dhcp-option DNS 1.0.0.1"
  224. keepalive 5 30
  225. comp-lzo
  226. persist-key
  227. persist-tun
  228. status /var/log/openvpn/server-tcp-1194.log
  229. verb 3
  230. EOF
  231. # Buat config server UDP 2200
  232. cat > /etc/openvpn/server-udp-2200.conf <<-EOF3
  233. port 2200
  234. proto udp
  235. dev tun
  236. ca ca.crt
  237. cert server.crt
  238. key server.key
  239. dh dh2048.pem
  240. plugin /usr/lib/openvpn/openvpn-plugin-auth-pam.so login
  241. verify-client-cert none
  242. username-as-common-name
  243. server 10.7.0.0 255.255.255.0
  244. ifconfig-pool-persist ipp.txt
  245. push "redirect-gateway def1 bypass-dhcp"
  246. push "dhcp-option DNS 1.1.1.1"
  247. push "dhcp-option DNS 1.0.0.1"
  248. keepalive 5 30
  249. comp-lzo
  250. persist-key
  251. persist-tun
  252. status /var/log/openvpn/server-udp-2200.log
  253. verb 3
  254. EOF3
  255. # restart openvpn dan cek status openvpn
  256. systemctl enable --now openvpn-server@server-tcp-1194
  257. systemctl enable --now openvpn-server@server-udp-2200
  258. /etc/init.d/openvpn restart
  259. /etc/init.d/openvpn status
  260. # Buat config client TCP 1194
  261. cat > /etc/openvpn/client-tcp-1194.ovpn <<-END
  262. # OVPN CLIENT-TCP CONFIG
  263. # ----------------------------
  264. setenv FRIENDLY_NAME $MySentev
  265. setenv CLIENT_CERT 0
  266. client
  267. dev tun
  268. proto tcp
  269. remote xxxxxxxxx 1194
  270. # back-quary or back inject method
  271. # remote "IP:PORT@bughost.yourdomain.com/
  272. resolv-retry infinite
  273. route-method exe
  274. nobind
  275. persist-key
  276. persist-tun
  277. auth-user-pass
  278. comp-lzo
  279. verb 3
  280. ## [1] ##
  281. # http-proxy-option CUSTOM-HEADER Protocol HTTP/1.1
  282. # http-proxy-option CUSTOM-HEADER Host bughost.yourdomain.com
  283. ## [2] ##
  284. # "http-proxy-option CUSTOM-HEADER HTTP/1.1" or "http-proxy-option VERSION 1.1"
  285. # http-proxy-option CUSTOM-HEADER Host bughost.yourdomain.com
  286. # http-proxy-option CUSTOM-HEADER X-Forward-Host bughost.yourdomain.com
  287. # http-proxy-option CUSTOM-HEADER X-Forwarded-For bughost.yourdomain.com
  288. # http-proxy-option CUSTOM-HEADER Referrer bughost.yourdomain.com
  289. ## 3 ##
  290. # http-proxy-option CUSTOM-HEADER Host bughost.yourdomain.com
  291. # http-proxy-option CUSTOM-HEADER X-Forwarded-For bughost.yourdomain.com
  292. # http-proxy-option CUSTOM-HEADER Referrer bughost.yourdomain.com
  293. #
  294. ## [3] [NEW proxy-option] ##
  295. # http-proxy-option CUSTOM-HEADER CONNECT HTTP/1.1
  296. # http-proxy-option CUSTOM-HEADER Host bughost.yourdomain.com
  297. # http-proxy-option CUSTOM-HEADER X-Online-Host bughost.yourdomain.com
  298. # http-proxy-option CUSTOM-HEADER ""
  299. # http-proxy-option CUSTOM-HEADER "PUT http://bughost.yourdomain.com/ HTTP/1.1"
  300. # http-proxy-option CUSTOM-HEADER X-Forward-Host bughost.yourdomain.com
  301. # http-proxy-option CUSTOM-HEADER Connection:Keep-Alive
  302. END
  303. sed -i $MYIP2 /etc/openvpn/client-tcp-1194.ovpn;
  304. # Buat config client UDP 2200
  305. cat > /etc/openvpn/client-udp-2200.ovpn <<-END2
  306. # OVPN CLIENT-TCP CONFIG
  307. # ----------------------------
  308. setenv FRIENDLY_NAME $MySentev
  309. setenv CLIENT_CERT 0
  310. client
  311. dev tun
  312. proto udp
  313. remote xxxxxxxxx 2200
  314. resolv-retry infinite
  315. route-method exe
  316. nobind
  317. persist-key
  318. persist-tun
  319. auth-user-pass
  320. comp-lzo
  321. verb 3
  322. END2
  323. sed -i $MYIP2 /etc/openvpn/client-udp-2200.ovpn;
  324. # Buat config client SSL
  325. cat > /etc/openvpn/client-tcp-ssl.ovpn <<-END3
  326. # OVPN CLIENT-TCP-SSL CONFIG
  327. # ----------------------------
  328. setenv FRIENDLY_NAME $MySentev
  329. setenv CLIENT_CERT 0
  330. client
  331. dev tun
  332. proto tcp
  333. remote xxxxxxxxx 992
  334. resolv-retry infinite
  335. route-method exe
  336. nobind
  337. persist-key
  338. persist-tun
  339. auth-user-pass
  340. comp-lzo
  341. verb 3
  342. ## [1] ##
  343. # http-proxy-option CUSTOM-HEADER Protocol HTTP/1.1
  344. # http-proxy-option CUSTOM-HEADER Host bughost.yourdomain.com
  345. ## [2] ##
  346. # "http-proxy-option CUSTOM-HEADER HTTP/1.1" or "http-proxy-option VERSION 1.1"
  347. # http-proxy-option CUSTOM-HEADER Host bughost.yourdomain.com
  348. # http-proxy-option CUSTOM-HEADER X-Forward-Host bughost.yourdomain.com
  349. # http-proxy-option CUSTOM-HEADER X-Forwarded-For bughost.yourdomain.com
  350. # http-proxy-option CUSTOM-HEADER Referrer bughost.yourdomain.com
  351. ## 3 ##
  352. # http-proxy-option CUSTOM-HEADER Host bughost.yourdomain.com
  353. # http-proxy-option CUSTOM-HEADER X-Forwarded-For bughost.yourdomain.com
  354. # http-proxy-option CUSTOM-HEADER Referrer bughost.yourdomain.com
  355. #
  356. ## [3] [NEW proxy-option] ##
  357. # http-proxy-option CUSTOM-HEADER CONNECT HTTP/1.1
  358. # http-proxy-option CUSTOM-HEADER Host bughost.yourdomain.com
  359. # http-proxy-option CUSTOM-HEADER X-Online-Host bughost.yourdomain.com
  360. # http-proxy-option CUSTOM-HEADER ""
  361. # http-proxy-option CUSTOM-HEADER "PUT http://bughost.yourdomain.com/ HTTP/1.1"
  362. # http-proxy-option CUSTOM-HEADER X-Forward-Host bughost.yourdomain.com
  363. # http-proxy-option CUSTOM-HEADER Connection:Keep-Alive
  364. END3
  365. sed -i $MYIP2 /etc/openvpn/client-tcp-ssl.ovpn;
  366. cd
  367. # pada tulisan xxx ganti dengan alamat ip address VPS anda
  368. /etc/init.d/openvpn restart
  369. # Enter the certificate into the TCP 1194 client .
  370. echo '<ca>' >> /etc/openvpn/client-tcp-1194.ovpn
  371. cat '/etc/openvpn/server/ca.crt' >> /etc/openvpn/client-tcp-1194.ovpn
  372. echo '</ca>' >> /etc/openvpn/client-tcp-1194.ovpn
  373. # Copy config OpenVPN client ke home directory root agar mudah didownload ( TCP 1194 )
  374. cp /etc/openvpn/client-tcp-1194.ovpn /home/vps/public_html/client-tcp-1194.ovpn
  375. # 2200
  376. # Enter the certificate into the UDP 2200 client config
  377. cho '<ca>' >> /etc/openvpn/client-udp-2200.ovpn
  378. cat '/etc/openvpn/ca.crt' >> /etc/openvpn/client-udp-2200.ovpn
  379. echo '</ca>' >> /etc/openvpn/client-udp-2200.ovpn
  380. # Copy config OpenVPN client ke home directory root agar mudah didownload ( UDP 2200 )
  381. cp /etc/openvpn/client-udp-2200.ovpn /home/vps/public_html/client-udp-2200.ovpn
  382. # Enter the certificate into the config SSL client .
  383. echo '<ca>' >> /etc/openvpn/client-tcp-ssl.ovpn
  384. cat '/etc/openvpn/server/ca.crt' >> /etc/openvpn/client-tcp-ssl.ovpn
  385. echo '</ca>' >> /etc/openvpn/client-tcp-ssl.ovpn
  386. # Copy config OpenVPN client ke home directory root agar mudah didownload ( SSL )
  387. cp /etc/openvpn/client-tcp-ssl.ovpn /home/vps/public_html/client-tcp-ssl.ovpn
  388. # allow ufw
  389. apt-get install ufw
  390. ufw allow ssh
  391. ufw allow 1194/tcp
  392. ufw allow 81/tcp
  393. ufw allow 2200/udp
  394. #firewall untuk memperbolehkan akses UDP dan akses jalur TCP
  395. iptables -t nat -I POSTROUTING -s 10.6.0.0/24 -o $ANU -j MASQUERADE
  396. iptables -t nat -I POSTROUTING -s 10.7.0.0/24 -o $ANU -j MASQUERADE
  397. iptables-save > /etc/iptables.up.rules
  398. chmod +x /etc/iptables.up.rules
  399. iptables-restore -t < /etc/iptables.up.rules
  400. netfilter-persistent save
  401. netfilter-persistent reload
  402. # Restart service openvpn
  403. systemctl enable openvpn
  404. systemctl start openvpn
  405. /etc/init.d/openvpn restart
  406. # Delete script
  407. history -c
  408. sleep 1
  409. rm -f /root/vpn.sh