Redirect a connection with Iptables

13 Jan

Object: Redirect port 995 to 9995

# First allow port 9995 into your firewall:

-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 9995 -j ACCEPT

# Now redirect all connections to port 995 to 9995;
-A PREROUTING -p tcp –dport 995 -j REDIRECT –to 9995

# You might also want to put it in the OUTPUT chain so you can “telnet localhost 995”
-A OUTPUT -p tcp –dport 995 -j REDIRECT –to 9995

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: