|
35 | 35 | echo -e "7. backup HexaSoftwareTech" |
36 | 36 | echo -e "8. backup Npanel" |
37 | 37 | echo -e "9. backup Marzban" |
38 | | - echo -e "10. Exit" |
| 38 | + echo -e "10. tunel ip-forward" |
| 39 | + echo -e "11. Exit" |
| 40 | + echo " " |
39 | 41 | read -p "Please Select Action: " choice |
40 | 42 | echo " " |
41 | 43 |
|
@@ -301,7 +303,46 @@ elif [ "$choice" = "9" ]; then |
301 | 303 | echo -e "\xE2\x98\x85 \e[94mThe backup settings have been successfully completed.\033[0m\n" |
302 | 304 |
|
303 | 305 |
|
304 | | -elif [ "$choice" = "9" ]; then |
| 306 | + elif [ "$choice" = "10" ]; then |
| 307 | + |
| 308 | + wait |
| 309 | + |
| 310 | + # install |
| 311 | + sudo apt-get install iptables -y |
| 312 | + sudo apt update && apt upgrade -y |
| 313 | + |
| 314 | + echo " " |
| 315 | + |
| 316 | + printf "\e[33m[!] \e[36mEnter ip iran: \033[0m" |
| 317 | + read ipiran |
| 318 | + printf "\e[33m[!] \e[36mEnter port iran: \033[0m" |
| 319 | + read portiran |
| 320 | + printf "\e[33m[!] \e[36mEnter ip kharej: \033[0m" |
| 321 | + read ipkharej |
| 322 | + echo " " |
| 323 | + if [ "$ipiran" = "" ] || [ "$portiran" = "" ] || [ "$ipkharej" = "" ]; then |
| 324 | + exit |
| 325 | + fi |
| 326 | + |
| 327 | + sysctl net.ipv4.ip_forward=1 |
| 328 | + iptables -t nat -A PREROUTING -p tcp --dport $portiran -j DNAT --to-destination $ipiran |
| 329 | + iptables -t nat -A PREROUTING -j DNAT --to-destination $ipkharej |
| 330 | + iptables -t nat -A POSTROUTING -j MASQUERADE |
| 331 | + |
| 332 | + echo "#!/bin/sh -e" >> /etc/rc.local |
| 333 | + echo "sysctl net.ipv4.ip_forward=1" >> /etc/rc.local |
| 334 | + echo "iptables -t nat -A PREROUTING -p tcp --dport ${portiran} -j DNAT --to-destination ${ipiran}" >> /etc/rc.local |
| 335 | + echo "iptables -t nat -A PREROUTING -j DNAT --to-destination ${ipkharej}" >> /etc/rc.local |
| 336 | + echo "iptables -t nat -A POSTROUTING -j MASQUERADE" >> /etc/rc.local |
| 337 | + echo "exit 0" >> /etc/rc.local |
| 338 | + |
| 339 | + chmod +x /etc/rc.local |
| 340 | + |
| 341 | + wait |
| 342 | + |
| 343 | + echo -e "\n\e[92mYour ip forward tunnel has been set up successfully!\033[0m\n" |
| 344 | + |
| 345 | +elif [ "$choice" = "11" ]; then |
305 | 346 |
|
306 | 347 | exit |
307 | 348 |
|
|
0 commit comments