Skip to content

Instantly share code, notes, and snippets.

@kingtuna
Created September 22, 2016 07:00
Show Gist options
  • Save kingtuna/6d5165537307e309c1018efeb64b1423 to your computer and use it in GitHub Desktop.
Save kingtuna/6d5165537307e309c1018efeb64b1423 to your computer and use it in GitHub Desktop.
iptables rules for forwarding all ports except 22 tcp and udp to an ip
iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 1:21 -j DNAT --to-destination 192.168.250.133:8080
iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 23:65535 -j DNAT --to-destination 192.168.250.133:8080
iptables -A PREROUTING -t nat -i eth0 -p udp --dport 1:65535 -j DNAT --to-destination 192.168.250.133:1024
@kingtuna
Copy link
Author

iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 1:21 -j DNAT --to-destination 192.168.250.133:8080
iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 23:65535 -j DNAT --to-destination 192.168.250.133:8080
iptables -A PREROUTING -t nat -i eth0 -p udp --dport 1:65535 -j DNAT --to-destination 192.168.250.133:1024

iptables -t nat -A PREROUTING -p tcp --dport 1:21 -j REDIRECT --to-ports 8080
iptables -t nat -A PREROUTING -p tcp --dport 23:65535 -j REDIRECT --to-ports 8080
iptables -t nat -A PREROUTING -p udp --dport 1:65535 -j REDIRECT --to-ports 1024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment