[CentOS] port forwarding using iptables

Robert Spangler mlists at zoominternet.net
Wed Nov 25 22:06:48 UTC 2009


On Wednesday 25 November 2009 13:57, Boris Epstein wrote:

>  Happy Thanksgiving!

Same to you too.

>  Does anybody know if there is a convenient utility to configure
>  iptables on a CentOS 5.4 or 5.3 machine to do port forwarding? And if
>  not, where and how does one put the requisite commands?

I do all my iptables configuring from the command line.  iptables config is 
store in /etc/sysconfig/iptables.  This Tutorial for iptables should be able 
to help you.

http://www.zoominternet.net/~lazydog/iptables-tutorial.html

Port forwarding is really not that hard.  The big question is if the 
forwarding to another port is on the same box or will you be forwarding it 
onto another box?  If it is staying local then you want to look at REDIRECT 
not forwarding. I.e.,

iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8080

If you are truly going to forward it onto another box then you need to look at 
DNAT.


-- 

Regards
Robert

Linux User #296285
http://counter.li.org


More information about the CentOS mailing list