Skip to content

Commit 12f1884

Browse files
authored
Add ip forward tunnel
1 parent afa6985 commit 12f1884

File tree

1 file changed

+43
-2
lines changed

1 file changed

+43
-2
lines changed

install.sh

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ fi
3535
echo -e "7. backup HexaSoftwareTech"
3636
echo -e "8. backup Npanel"
3737
echo -e "9. backup Marzban"
38-
echo -e "10. Exit"
38+
echo -e "10. tunel ip-forward"
39+
echo -e "11. Exit"
40+
echo " "
3941
read -p "Please Select Action: " choice
4042
echo " "
4143

@@ -301,7 +303,46 @@ elif [ "$choice" = "9" ]; then
301303
echo -e "\xE2\x98\x85 \e[94mThe backup settings have been successfully completed.\033[0m\n"
302304

303305

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
305346

306347
exit
307348

0 commit comments

Comments
 (0)