IPTables

From Leo's Notes
Revision as of 00:57, 12 May 2013 by Leo (talk | contribs) (Created page with " == Redirect Outgoing Traffic to Local Port == To redirect traffic destined to 1.2.3.4:443 to localhost:8080, use the REDIRECT directive: iptables -t nat -A OUTPUT -p tcp -d...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
This page was last edited on 12 May 2013, at 00:57.

Redirect Outgoing Traffic to Local Port

To redirect traffic destined to 1.2.3.4:443 to localhost:8080, use the REDIRECT directive:

iptables -t nat -A OUTPUT -p tcp -d 1.2.3.4 --dport 443 -j REDIRECT --to-ports 8080

If you want to redirect traffic to a particular destination rather than 127.0.0.1 (or the primary interface's IP) use DNAT:

iptables -t nat -A OUTPUT -p udp -d 1.2.3.4 --dport 443 -j DNAT --to-destination 9.8.7.6:8080