Last active
February 28, 2023 09:18
-
-
Save Max95Cohen/d1d48743724c99e7b6b5976a7eeea586 to your computer and use it in GitHub Desktop.
iptables examples
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
# show, delete | |
iptables -t nat -v -L PREROUTING -n --line-number | |
iptables -t nat -D PREROUTING 5 | |
# forward | |
iptables -t nat -A PREROUTING -i ens3 -p tcp --dport 33080 -j DNAT --to 10.0.27.67:33080 | |
# Global IP to Local IP Ubuntu | |
iptables -t nat -A OUTPUT -p all -d 123.45.67.89 -j DNAT --to-destination 127.0.0.1 | |
# forward port to another server | |
iptables -t nat -A PREROUTING -i eth0 -p tcp -d 10.0.11.12 --dport 2222 -j DNAT --to-destination 192.168.10.7:22 | |
iptables -t nat -A POSTROUTING -d 192.168.10.7 -p tcp --dport 22 -j MASQUERADE | |
# port range | |
iptables -t nat -A PREROUTING -p tcp --dport 40000:50000 -j DNAT --to-destination 192.168.10.7:40000-50000 | |
# drop ICMP packet from output | |
iptables -A INPUT -p icmp --icmp-type 8 -j DROP |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment