Last active
November 14, 2022 01:33
-
-
Save zarza/335234deb37ec038c6957a8ea0d4efcd to your computer and use it in GitHub Desktop.
Port forwarding from eth0 to wireguard
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# VESTA PORTS # | |
#<?php | |
#// Enter your code here, enjoy! | |
#$array = explode(',','21,22,25,53,80,443,110,143,465,783,993,995,3306,8083'); | |
#foreach( $array as $port ){ | |
#echo 'iptables -i eth0 -I FORWARD -d 10.7.0.2 -m comment --comment "Accept to forward ssh traffic" -m tcp -p tcp --dport '.$port.' -j ACCEPT' . PHP_EOL; | |
#echo 'iptables -i eth0 -I FORWARD -m comment --comment "Accept to forward ssh return traffic" -s 10.7.0.2 -m tcp -p tcp --sport '.$port.' -j ACCEPT' . PHP_EOL; | |
#echo 'iptables -i eth0 -t nat -I PREROUTING -m tcp -p tcp --dport '.$port.' -m comment --comment "redirect pkts to virtual machine" -j DNAT --to-destination 10.7.0.2:'.$port.'' . PHP_EOL; | |
#} | |
iptables -I FORWARD -d 10.7.0.2 -m comment --comment "Accept to forward ssh traffic" -m tcp -p tcp --dport 21 -j ACCEPT | |
iptables -I FORWARD -m comment --comment "Accept to forward ssh return traffic" -s 10.7.0.2 -m tcp -p tcp --sport 21 -j ACCEPT | |
iptables -t nat -I PREROUTING -m tcp -p tcp --dport 21 -m comment --comment "redirect pkts to virtual machine" -j DNAT --to-destination 10.7.0.2:21 | |
iptables -I FORWARD -d 10.7.0.2 -m comment --comment "Accept to forward ssh traffic" -m tcp -p tcp --dport 25 -j ACCEPT | |
iptables -i eth0 -I FORWARD -d 10.7.0.2 -m comment --comment "Accept to forward ssh traffic" -m tcp -p tcp --dport 21 -j ACCEPT | |
iptables -i eth0 -I FORWARD -m comment --comment "Accept to forward ssh return traffic" -s 10.7.0.2 -m tcp -p tcp --sport 21 -j ACCEPT | |
iptables -i eth0 -t nat -I PREROUTING -m tcp -p tcp --dport 21 -m comment --comment "redirect pkts to virtual machine" -j DNAT --to-destination 10.7.0.2:21 | |
iptables -i eth0 -I FORWARD -d 10.7.0.2 -m comment --comment "Accept to forward ssh traffic" -m tcp -p tcp --dport 22 -j ACCEPT | |
iptables -i eth0 -I FORWARD -m comment --comment "Accept to forward ssh return traffic" -s 10.7.0.2 -m tcp -p tcp --sport 22 -j ACCEPT | |
iptables -i eth0 -t nat -I PREROUTING -m tcp -p tcp --dport 22 -m comment --comment "redirect pkts to virtual machine" -j DNAT --to-destination 10.7.0.2:22 | |
iptables -i eth0 -I FORWARD -d 10.7.0.2 -m comment --comment "Accept to forward ssh traffic" -m tcp -p tcp --dport 25 -j ACCEPT | |
iptables -i eth0 -I FORWARD -m comment --comment "Accept to forward ssh return traffic" -s 10.7.0.2 -m tcp -p tcp --sport 25 -j ACCEPT | |
iptables -i eth0 -t nat -I PREROUTING -m tcp -p tcp --dport 25 -m comment --comment "redirect pkts to virtual machine" -j DNAT --to-destination 10.7.0.2:25 | |
iptables -i eth0 -I FORWARD -d 10.7.0.2 -m comment --comment "Accept to forward ssh traffic" -m tcp -p tcp --dport 53 -j ACCEPT | |
iptables -i eth0 -I FORWARD -m comment --comment "Accept to forward ssh return traffic" -s 10.7.0.2 -m tcp -p tcp --sport 53 -j ACCEPT | |
iptables -i eth0 -t nat -I PREROUTING -m tcp -p tcp --dport 53 -m comment --comment "redirect pkts to virtual machine" -j DNAT --to-destination 10.7.0.2:53 | |
iptables -i eth0 -I FORWARD -d 10.7.0.2 -m comment --comment "Accept to forward ssh traffic" -m tcp -p tcp --dport 80 -j ACCEPT | |
iptables -i eth0 -I FORWARD -m comment --comment "Accept to forward ssh return traffic" -s 10.7.0.2 -m tcp -p tcp --sport 80 -j ACCEPT | |
iptables -i eth0 -t nat -I PREROUTING -m tcp -p tcp --dport 80 -m comment --comment "redirect pkts to virtual machine" -j DNAT --to-destination 10.7.0.2:80 | |
iptables -i eth0 -I FORWARD -d 10.7.0.2 -m comment --comment "Accept to forward ssh traffic" -m tcp -p tcp --dport 443 -j ACCEPT | |
iptables -i eth0 -I FORWARD -m comment --comment "Accept to forward ssh return traffic" -s 10.7.0.2 -m tcp -p tcp --sport 443 -j ACCEPT | |
iptables -i eth0 -t nat -I PREROUTING -m tcp -p tcp --dport 443 -m comment --comment "redirect pkts to virtual machine" -j DNAT --to-destination 10.7.0.2:443 | |
iptables -i eth0 -I FORWARD -d 10.7.0.2 -m comment --comment "Accept to forward ssh traffic" -m tcp -p tcp --dport 110 -j ACCEPT | |
iptables -i eth0 -I FORWARD -m comment --comment "Accept to forward ssh return traffic" -s 10.7.0.2 -m tcp -p tcp --sport 110 -j ACCEPT | |
iptables -i eth0 -t nat -I PREROUTING -m tcp -p tcp --dport 110 -m comment --comment "redirect pkts to virtual machine" -j DNAT --to-destination 10.7.0.2:110 | |
iptables -i eth0 -I FORWARD -d 10.7.0.2 -m comment --comment "Accept to forward ssh traffic" -m tcp -p tcp --dport 143 -j ACCEPT | |
iptables -i eth0 -I FORWARD -m comment --comment "Accept to forward ssh return traffic" -s 10.7.0.2 -m tcp -p tcp --sport 143 -j ACCEPT | |
iptables -i eth0 -t nat -I PREROUTING -m tcp -p tcp --dport 143 -m comment --comment "redirect pkts to virtual machine" -j DNAT --to-destination 10.7.0.2:143 | |
iptables -i eth0 -I FORWARD -d 10.7.0.2 -m comment --comment "Accept to forward ssh traffic" -m tcp -p tcp --dport 465 -j ACCEPT | |
iptables -i eth0 -I FORWARD -m comment --comment "Accept to forward ssh return traffic" -s 10.7.0.2 -m tcp -p tcp --sport 465 -j ACCEPT | |
iptables -i eth0 -t nat -I PREROUTING -m tcp -p tcp --dport 465 -m comment --comment "redirect pkts to virtual machine" -j DNAT --to-destination 10.7.0.2:465 | |
iptables -i eth0 -I FORWARD -d 10.7.0.2 -m comment --comment "Accept to forward ssh traffic" -m tcp -p tcp --dport 783 -j ACCEPT | |
iptables -i eth0 -I FORWARD -m comment --comment "Accept to forward ssh return traffic" -s 10.7.0.2 -m tcp -p tcp --sport 783 -j ACCEPT | |
iptables -i eth0 -t nat -I PREROUTING -m tcp -p tcp --dport 783 -m comment --comment "redirect pkts to virtual machine" -j DNAT --to-destination 10.7.0.2:783 | |
iptables -i eth0 -I FORWARD -d 10.7.0.2 -m comment --comment "Accept to forward ssh traffic" -m tcp -p tcp --dport 993 -j ACCEPT | |
iptables -i eth0 -I FORWARD -m comment --comment "Accept to forward ssh return traffic" -s 10.7.0.2 -m tcp -p tcp --sport 993 -j ACCEPT | |
iptables -i eth0 -t nat -I PREROUTING -m tcp -p tcp --dport 993 -m comment --comment "redirect pkts to virtual machine" -j DNAT --to-destination 10.7.0.2:993 | |
iptables -i eth0 -I FORWARD -d 10.7.0.2 -m comment --comment "Accept to forward ssh traffic" -m tcp -p tcp --dport 995 -j ACCEPT | |
iptables -i eth0 -I FORWARD -m comment --comment "Accept to forward ssh return traffic" -s 10.7.0.2 -m tcp -p tcp --sport 995 -j ACCEPT | |
iptables -i eth0 -t nat -I PREROUTING -m tcp -p tcp --dport 995 -m comment --comment "redirect pkts to virtual machine" -j DNAT --to-destination 10.7.0.2:995 | |
iptables -i eth0 -I FORWARD -d 10.7.0.2 -m comment --comment "Accept to forward ssh traffic" -m tcp -p tcp --dport 3306 -j ACCEPT | |
iptables -i eth0 -I FORWARD -m comment --comment "Accept to forward ssh return traffic" -s 10.7.0.2 -m tcp -p tcp --sport 3306 -j ACCEPT | |
iptables -i eth0 -t nat -I PREROUTING -m tcp -p tcp --dport 3306 -m comment --comment "redirect pkts to virtual machine" -j DNAT --to-destination 10.7.0.2:3306 | |
iptables -i eth0 -I FORWARD -d 10.7.0.2 -m comment --comment "Accept to forward ssh traffic" -m tcp -p tcp --dport 8083 -j ACCEPT | |
iptables -i eth0 -I FORWARD -m comment --comment "Accept to forward ssh return traffic" -s 10.7.0.2 -m tcp -p tcp --sport 8083 -j ACCEPT | |
iptables -i eth0 -t nat -I PREROUTING -m tcp -p tcp --dport 8083 -m comment --comment "redirect pkts to virtual machine" -j DNAT --to-destination 10.7.0.2:8083 | |
iptables -t nat -I POSTROUTING -m comment --comment "NAT the src ip" -d 10.7.0.2 -o wg0 -j MASQUERADE | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment