Created
December 17, 2015 12:52
-
-
Save jriguera/4d038a3a9576513f72cf to your computer and use it in GitHub Desktop.
Iptables redirect port
This file contains hidden or 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
# All incoming trafic (mainly via eth2) will be redirected to 2005 (old graphite relay) | |
iptables -t nat -A PREROUTING -p tcp --dport 2003 -j REDIRECT --to-port 2005 | |
iptables -t nat -A PREROUTING -p udp --dport 2003 -j REDIRECT --to-port 2005 | |
# Another example using ips | |
#iptables -t nat -A PREROUTING -i eth2 -p udp -d 10.9.2.197 --dport 2003 -j REDIRECT --to-port 2005 | |
# loopback traffic do not go via PREROUTING chain | |
iptables -t nat -A OUTPUT -o lo -p tcp --dport 2003 -j REDIRECT --to-port 2005 | |
# just the same but using ips instead of interfaces (for udp) | |
iptables -t nat -A OUTPUT --src 0/0 --dst 127.0.0.1 -p udp --dport 2003 -j REDIRECT --to-port 2005 | |
# Show it | |
iptables -t nat -L -n -v |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment