ins-vt.sh 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690
  1. #!/bin/bash
  2. domain=$(cat /root/domain)
  3. apt install iptables iptables-persistent -y
  4. apt install curl socat xz-utils wget apt-transport-https gnupg gnupg2 gnupg1 dnsutils lsb-release -y
  5. apt install socat cron bash-completion ntpdate -y
  6. ntpdate pool.ntp.org
  7. apt -y install chrony
  8. timedatectl set-ntp true
  9. systemctl enable chronyd && systemctl restart chronyd
  10. systemctl enable chrony && systemctl restart chrony
  11. timedatectl set-timezone Asia/Kuala_Lumpur
  12. chronyc sourcestats -v
  13. chronyc tracking -v
  14. date
  15. mkdir -p /etc/trojan/
  16. touch /etc/trojan/akun.conf
  17. # install v2ray
  18. wget https://raw.githubusercontent.com/alifnurmareta/bc/main/go.sh && chmod +x go.sh && ./go.sh
  19. rm -f /root/go.sh
  20. bash -c "$(wget -O- https://raw.githubusercontent.com/trojan-gfw/trojan-quickstart/master/trojan-quickstart.sh)"
  21. mkdir /root/.acme.sh
  22. curl https://acme-install.netlify.app/acme.sh -o /root/.acme.sh/acme.sh
  23. chmod +x /root/.acme.sh/acme.sh
  24. /root/.acme.sh/acme.sh --issue -d $domain --standalone -k ec-256
  25. ~/.acme.sh/acme.sh --installcert -d $domain --fullchainpath /etc/v2ray/v2ray.crt --keypath /etc/v2ray/v2ray.key --ecc
  26. service squid start
  27. uuid=$(cat /proc/sys/kernel/random/uuid)
  28. cat> /etc/v2ray/config.json << END
  29. {
  30. "log": {
  31. "access": "/var/log/v2ray/access2.log",
  32. "error": "/var/log/v2ray/error.log",
  33. "loglevel": "info"
  34. },
  35. "inbounds": [
  36. {
  37. "port": 8443,
  38. "protocol": "vmess",
  39. "settings": {
  40. "clients": [
  41. {
  42. "id": "${uuid}"
  43. #tls
  44. }
  45. ],
  46. "decryption": "none"
  47. },
  48. "streamSettings": {
  49. "network": "ws",
  50. "security": "tls",
  51. "tlsSettings": {
  52. "certificates": [
  53. {
  54. "certificateFile": "/etc/v2ray/v2ray.crt",
  55. "keyFile": "/etc/v2ray/v2ray.key"
  56. }
  57. ]
  58. },
  59. "wsSettings": {
  60. "path": "/v2ray",
  61. "headers": {
  62. "Host": ""
  63. }
  64. },
  65. "quicSettings": {},
  66. "sockopt": {
  67. "mark": 0,
  68. "tcpFastOpen": true
  69. }
  70. },
  71. "sniffing": {
  72. "enabled": true,
  73. "destOverride": [
  74. "http",
  75. "tls"
  76. ]
  77. },
  78. "domain": "$domain"
  79. }
  80. ],
  81. "outbounds": [
  82. {
  83. "tag": "IP4_out",
  84. "protocol": "freedom",
  85. "settings": {}
  86. },
  87. {
  88. "tag": "IP6_out",
  89. "protocol": "freedom",
  90. "settings": {
  91. "domainStrategy": "UseIPv6"
  92. }
  93. },
  94. {
  95. "protocol": "blackhole",
  96. "settings": {},
  97. "tag": "blocked"
  98. }
  99. ],
  100. "routing": {
  101. "rules": [
  102. {
  103. "type": "field",
  104. "outboundTag": "IP6_out",
  105. "domain": [
  106. "geosite:netflix"
  107. ]
  108. },
  109. {
  110. "type": "field",
  111. "outboundTag": "IP4_out",
  112. "network": "udp,tcp"
  113. },
  114. {
  115. "type": "field",
  116. "ip": [
  117. "0.0.0.0/8",
  118. "10.0.0.0/8",
  119. "100.64.0.0/10",
  120. "169.254.0.0/16",
  121. "172.16.0.0/12",
  122. "192.0.0.0/24",
  123. "192.0.2.0/24",
  124. "192.168.0.0/16",
  125. "198.18.0.0/15",
  126. "198.51.100.0/24",
  127. "203.0.113.0/24",
  128. "::1/128",
  129. "fc00::/7",
  130. "fe80::/10"
  131. ],
  132. "outboundTag": "blocked"
  133. }
  134. ]
  135. }
  136. }
  137. END
  138. cat> /etc/v2ray/none.json << END
  139. {
  140. "log": {
  141. "access": "/var/log/v2ray/access2.log",
  142. "error": "/var/log/v2ray/error.log",
  143. "loglevel": "info"
  144. },
  145. "inbounds": [
  146. {
  147. "port": 80,
  148. "protocol": "vmess",
  149. "settings": {
  150. "clients": [
  151. {
  152. "id": "${uuid}"
  153. #none
  154. }
  155. ],
  156. "decryption": "none"
  157. },
  158. "streamSettings": {
  159. "network": "ws",
  160. "wsSettings": {
  161. "path": "/v2ray",
  162. "headers": {
  163. "Host": ""
  164. }
  165. },
  166. "quicSettings": {},
  167. "sockopt": {
  168. "mark": 0,
  169. "tcpFastOpen": true
  170. }
  171. },
  172. "sniffing": {
  173. "enabled": true,
  174. "destOverride": [
  175. "http",
  176. "tls"
  177. ]
  178. },
  179. "domain": "$domain"
  180. }
  181. ],
  182. "outbounds": [
  183. {
  184. "tag": "IP4_out",
  185. "protocol": "freedom",
  186. "settings": {}
  187. },
  188. {
  189. "tag": "IP6_out",
  190. "protocol": "freedom",
  191. "settings": {
  192. "domainStrategy": "UseIPv6"
  193. }
  194. },
  195. {
  196. "protocol": "blackhole",
  197. "settings": {},
  198. "tag": "blocked"
  199. }
  200. ],
  201. "routing": {
  202. "rules": [
  203. {
  204. "type": "field",
  205. "outboundTag": "IP6_out",
  206. "domain": [
  207. "geosite:netflix"
  208. ]
  209. },
  210. {
  211. "type": "field",
  212. "outboundTag": "IP4_out",
  213. "network": "udp,tcp"
  214. },
  215. {
  216. "type": "field",
  217. "ip": [
  218. "0.0.0.0/8",
  219. "10.0.0.0/8",
  220. "100.64.0.0/10",
  221. "169.254.0.0/16",
  222. "172.16.0.0/12",
  223. "192.0.0.0/24",
  224. "192.0.2.0/24",
  225. "192.168.0.0/16",
  226. "198.18.0.0/15",
  227. "198.51.100.0/24",
  228. "203.0.113.0/24",
  229. "::1/128",
  230. "fc00::/7",
  231. "fe80::/10"
  232. ],
  233. "outboundTag": "blocked"
  234. }
  235. ]
  236. }
  237. }
  238. END
  239. cat> /etc/v2ray/vless.json << END
  240. {
  241. "log": {
  242. "access": "/var/log/v2ray/access2.log",
  243. "error": "/var/log/v2ray/error.log",
  244. "loglevel": "info"
  245. },
  246. "inbounds": [
  247. {
  248. "port": 8585,
  249. "protocol": "vless",
  250. "settings": {
  251. "clients": [
  252. {
  253. "id": "${uuid}"
  254. #tls
  255. }
  256. ],
  257. "decryption": "none"
  258. },
  259. "streamSettings": {
  260. "network": "ws",
  261. "security": "tls",
  262. "tlsSettings": {
  263. "certificates": [
  264. {
  265. "certificateFile": "/etc/v2ray/v2ray.crt",
  266. "keyFile": "/etc/v2ray/v2ray.key"
  267. }
  268. ]
  269. },
  270. "wsSettings": {
  271. "path": "/v2ray",
  272. "headers": {
  273. "Host": ""
  274. }
  275. },
  276. "quicSettings": {},
  277. "sockopt": {
  278. "mark": 0,
  279. "tcpFastOpen": true
  280. }
  281. },
  282. "sniffing": {
  283. "enabled": true,
  284. "destOverride": [
  285. "http",
  286. "tls"
  287. ]
  288. },
  289. "domain": "$domain"
  290. }
  291. ],
  292. "outbounds": [
  293. {
  294. "tag": "IP4_out",
  295. "protocol": "freedom",
  296. "settings": {}
  297. },
  298. {
  299. "tag": "IP6_out",
  300. "protocol": "freedom",
  301. "settings": {
  302. "domainStrategy": "UseIPv6"
  303. }
  304. },
  305. {
  306. "protocol": "blackhole",
  307. "settings": {},
  308. "tag": "blocked"
  309. }
  310. ],
  311. "routing": {
  312. "rules": [
  313. {
  314. "type": "field",
  315. "outboundTag": "IP6_out",
  316. "domain": [
  317. "geosite:netflix"
  318. ]
  319. },
  320. {
  321. "type": "field",
  322. "outboundTag": "IP4_out",
  323. "network": "udp,tcp"
  324. },
  325. {
  326. "type": "field",
  327. "ip": [
  328. "0.0.0.0/8",
  329. "10.0.0.0/8",
  330. "100.64.0.0/10",
  331. "169.254.0.0/16",
  332. "172.16.0.0/12",
  333. "192.0.0.0/24",
  334. "192.0.2.0/24",
  335. "192.168.0.0/16",
  336. "198.18.0.0/15",
  337. "198.51.100.0/24",
  338. "203.0.113.0/24",
  339. "::1/128",
  340. "fc00::/7",
  341. "fe80::/10"
  342. ],
  343. "outboundTag": "blocked"
  344. }
  345. ]
  346. }
  347. }
  348. END
  349. cat> /etc/v2ray/vnone.json << END
  350. {
  351. "log": {
  352. "access": "/var/log/v2ray/access2.log",
  353. "error": "/var/log/v2ray/error.log",
  354. "loglevel": "info"
  355. },
  356. "inbounds": [
  357. {
  358. "port": 8989,
  359. "protocol": "vless",
  360. "settings": {
  361. "clients": [
  362. {
  363. "id": "${uuid}"
  364. #none
  365. }
  366. ],
  367. "decryption": "none"
  368. },
  369. "streamSettings": {
  370. "network": "ws",
  371. "wsSettings": {
  372. "path": "/v2ray",
  373. "headers": {
  374. "Host": ""
  375. }
  376. },
  377. "quicSettings": {},
  378. "sockopt": {
  379. "mark": 0,
  380. "tcpFastOpen": true
  381. }
  382. },
  383. "sniffing": {
  384. "enabled": true,
  385. "destOverride": [
  386. "http",
  387. "tls"
  388. ]
  389. },
  390. "domain": "$domain"
  391. }
  392. ],
  393. "outbounds": [
  394. {
  395. "tag": "IP4_out",
  396. "protocol": "freedom",
  397. "settings": {}
  398. },
  399. {
  400. "tag": "IP6_out",
  401. "protocol": "freedom",
  402. "settings": {
  403. "domainStrategy": "UseIPv6"
  404. }
  405. },
  406. {
  407. "protocol": "blackhole",
  408. "settings": {},
  409. "tag": "blocked"
  410. }
  411. ],
  412. "routing": {
  413. "rules": [
  414. {
  415. "type": "field",
  416. "outboundTag": "IP6_out",
  417. "domain": [
  418. "geosite:netflix"
  419. ]
  420. },
  421. {
  422. "type": "field",
  423. "outboundTag": "IP4_out",
  424. "network": "udp,tcp"
  425. },
  426. {
  427. "type": "field",
  428. "ip": [
  429. "0.0.0.0/8",
  430. "10.0.0.0/8",
  431. "100.64.0.0/10",
  432. "169.254.0.0/16",
  433. "172.16.0.0/12",
  434. "192.0.0.0/24",
  435. "192.0.2.0/24",
  436. "192.168.0.0/16",
  437. "198.18.0.0/15",
  438. "198.51.100.0/24",
  439. "203.0.113.0/24",
  440. "::1/128",
  441. "fc00::/7",
  442. "fe80::/10"
  443. ],
  444. "outboundTag": "blocked"
  445. }
  446. ]
  447. }
  448. }
  449. END
  450. cat> /etc/v2ray/mkcp.json << END
  451. {
  452. "log": {
  453. "access": "/var/log/v2ray/access.log",
  454. "error": "/var/log/v2ray/error.log",
  455. "loglevel": "info"
  456. },
  457. "inbounds": [
  458. {
  459. "port": 11063,
  460. "protocol": "vmess",
  461. "settings": {
  462. "clients": [
  463. {
  464. "id": "${uuid}"
  465. #mkcp
  466. }
  467. ]
  468. },
  469. "streamSettings": {
  470. "network": "kcp",
  471. "security": "none",
  472. "tlsSettings": {},
  473. "tcpSettings": {},
  474. "httpSettings": {},
  475. "kcpSettings": {
  476. "mtu": 1350,
  477. "tti": 50,
  478. "uplinkCapacity": 100,
  479. "downlinkCapacity": 100,
  480. "congestion": false,
  481. "readBufferSize": 2,
  482. "writeBufferSize": 2,
  483. "header": {
  484. "type": "dtls"
  485. }
  486. },
  487. "wsSettings": {},
  488. "quicSettings": {}
  489. },
  490. "sniffing": {
  491. "enabled": true,
  492. "destOverride": [
  493. "http",
  494. "tls"
  495. ]
  496. },
  497. "domain": "$domain"
  498. }
  499. ],
  500. "outbounds": [
  501. {
  502. "tag": "IP4_out",
  503. "protocol": "freedom",
  504. "settings": {}
  505. },
  506. {
  507. "tag": "IP6_out",
  508. "protocol": "freedom",
  509. "settings": {
  510. "domainStrategy": "UseIPv6"
  511. }
  512. },
  513. {
  514. "protocol": "blackhole",
  515. "settings": {},
  516. "tag": "blocked"
  517. }
  518. ],
  519. "routing": {
  520. "rules": [
  521. {
  522. "type": "field",
  523. "outboundTag": "IP6_out",
  524. "domain": [
  525. "geosite:netflix"
  526. ]
  527. },
  528. {
  529. "type": "field",
  530. "outboundTag": "IP4_out",
  531. "network": "udp,tcp"
  532. },
  533. {
  534. "type": "field",
  535. "ip": [
  536. "0.0.0.0/8",
  537. "10.0.0.0/8",
  538. "100.64.0.0/10",
  539. "169.254.0.0/16",
  540. "172.16.0.0/12",
  541. "192.0.0.0/24",
  542. "192.0.2.0/24",
  543. "192.168.0.0/16",
  544. "198.18.0.0/15",
  545. "198.51.100.0/24",
  546. "203.0.113.0/24",
  547. "::1/128",
  548. "fc00::/7",
  549. "fe80::/10"
  550. ],
  551. "outboundTag": "blocked"
  552. }
  553. ]
  554. }
  555. }
  556. END
  557. cat <<EOF > /etc/trojan/config.json
  558. {
  559. "run_type": "server",
  560. "local_addr": "0.0.0.0",
  561. "local_port": 2087,
  562. "remote_addr": "127.0.0.1",
  563. "remote_port": 2603,
  564. "password": [
  565. "$uuid"
  566. ],
  567. "log_level": 1,
  568. "ssl": {
  569. "cert": "/etc/v2ray/v2ray.crt",
  570. "key": "/etc/v2ray/v2ray.key",
  571. "key_password": "",
  572. "cipher": "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384",
  573. "cipher_tls13": "TLS_AES_128_GCM_SHA256:TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384",
  574. "prefer_server_cipher": true,
  575. "alpn": [
  576. "http/1.1"
  577. ],
  578. "reuse_session": true,
  579. "session_ticket": false,
  580. "session_timeout": 600,
  581. "plain_http_response": "",
  582. "curves": "",
  583. "dhparam": ""
  584. },
  585. "tcp": {
  586. "prefer_ipv4": false,
  587. "no_delay": true,
  588. "keep_alive": true,
  589. "reuse_port": false,
  590. "fast_open": false,
  591. "fast_open_qlen": 20
  592. },
  593. "mysql": {
  594. "enabled": false,
  595. "server_addr": "127.0.0.1",
  596. "server_port": 3306,
  597. "database": "trojan",
  598. "username": "trojan",
  599. "password": "",
  600. "key": "",
  601. "cert": "",
  602. "ca": ""
  603. }
  604. }
  605. EOF
  606. cat <<EOF> /etc/systemd/system/trojan.service
  607. [Unit]
  608. Description=Trojan
  609. Documentation=https://trojan-gfw.github.io/trojan/
  610. [Service]
  611. Type=simple
  612. ExecStart=/usr/local/bin/trojan -c /etc/trojan/config.json -l /var/log/trojan.log
  613. Type=simple
  614. KillMode=process
  615. Restart=no
  616. RestartSec=42s
  617. [Install]
  618. WantedBy=multi-user.target
  619. EOF
  620. cat <<EOF > /etc/trojan/uuid.txt
  621. $uuid
  622. EOF
  623. iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 2087 -j ACCEPT
  624. iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 8443 -j ACCEPT
  625. iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
  626. iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 2083 -j ACCEPT
  627. iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 8880 -j ACCEPT
  628. iptables -I INPUT -m state --state NEW -m udp -p udp --dport 11063 -j ACCEPT
  629. iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 11063 -j ACCEPT
  630. iptables -I INPUT -m state --state NEW -m udp -p udp --dport 2087 -j ACCEPT
  631. iptables -I INPUT -m state --state NEW -m udp -p udp --dport 8443 -j ACCEPT
  632. iptables -I INPUT -m state --state NEW -m udp -p udp --dport 80 -j ACCEPT
  633. iptables -I INPUT -m state --state NEW -m udp -p udp --dport 2083 -j ACCEPT
  634. iptables -I INPUT -m state --state NEW -m udp -p udp --dport 8880 -j ACCEPT
  635. iptables-save > /etc/iptables.up.rules
  636. iptables-restore -t < /etc/iptables.up.rules
  637. netfilter-persistent save
  638. netfilter-persistent reload
  639. systemctl daemon-reload
  640. systemctl enable v2ray@none.service
  641. systemctl start v2ray@none.service
  642. systemctl enable v2ray@vless.service
  643. systemctl start v2ray@vless.service
  644. systemctl enable v2ray@vnone.service
  645. systemctl start v2ray@vnone.service
  646. systemctl enable v2ray@mkcp.service
  647. systemctl start v2ray@mkcp.service
  648. systemctl restart trojan.service
  649. systemctl enable trojan.service
  650. systemctl restart trojan
  651. systemctl enable trojan
  652. systemctl restart v2ray
  653. systemctl enable v2ray
  654. systemctl start v2ray
  655. cd /usr/bin
  656. wget -O add-ws "https://raw.githubusercontent.com/alifnurmareta/bc/main/add-ws.sh"
  657. wget -O add-vless "https://raw.githubusercontent.com/alifnurmareta/bc/main/add-vless.sh"
  658. wget -O add-tr "https://raw.githubusercontent.com/alifnurmareta/bc/main/add-tr.sh"
  659. wget -O del-ws "https://raw.githubusercontent.com/alifnurmareta/bc/main/del-ws.sh"
  660. wget -O del-vless "https://raw.githubusercontent.com/alifnurmareta/bc/main/del-vless.sh"
  661. wget -O del-tr "https://raw.githubusercontent.com/alifnurmareta/bc/main/del-tr.sh"
  662. wget -O cek-ws "https://raw.githubusercontent.com/alifnurmareta/bc/main/cek-ws.sh"
  663. wget -O cek-vless "https://raw.githubusercontent.com/alifnurmareta/bc/main/cek-vless.sh"
  664. wget -O cek-tr "https://raw.githubusercontent.com/alifnurmareta/bc/main/cek-tr.sh"
  665. wget -O renew-ws "https://raw.githubusercontent.com/alifnurmareta/bc/main/renew-ws.sh"
  666. wget -O renew-vless "https://raw.githubusercontent.com/alifnurmareta/bc/main/renew-vless.sh"
  667. wget -O renew-tr "https://raw.githubusercontent.com/alifnurmareta/bc/main/renew-tr.sh"
  668. wget -O certv2ray "https://raw.githubusercontent.com/alifnurmareta/bc/main/cert.sh"
  669. chmod +x add-ws
  670. chmod +x add-vless
  671. chmod +x add-tr
  672. chmod +x del-ws
  673. chmod +x del-vless
  674. chmod +x del-tr
  675. chmod +x cek-ws
  676. chmod +x cek-vless
  677. chmod +x cek-tr
  678. chmod +x renew-ws
  679. chmod +x renew-vless
  680. chmod +x renew-tr
  681. chmod +x certv2ray
  682. cd
  683. rm -f ins-vt.sh
  684. mv /root/domain /etc/v2ray