[CentOS] local port redirect not working on Centos4

Sat Feb 4 06:51:02 UTC 2006
Craig White <craigwhite at azapple.com>

On Fri, 2006-02-03 at 22:35 -0800, Francois Caen wrote:
> Hello,
> 
> I want to redirect one local port to another. I am using the following:
> 
> iptables -t nat -A PREROUTING -p tcp --dport 7003 -j REDIRECT --to-ports 80
> 
> and testing it by telneting to localhost on port 7003. It works on
> Centos3, not on Centos4.
> 
> No luck with this either:
> iptables -t nat -A PREROUTING -p tcp --dport 7002 -j DNAT --to 127.0.0.1:80
> 
> Am I doing something wrong? Or did something change in 2.6? Tried
> googling this, no luck.
----
# cat /etc/sysctl.conf
# Kernel sysctl configuration file for Red Hat Linux
#
# For binary values, 0 is disabled, 1 is enabled.  See sysctl(8) and
# sysctl.conf(5) for more details.

# Controls IP packet forwarding
net.ipv4.ip_forward = 1

# Controls source route verification
net.ipv4.conf.default.rp_filter = 1

# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0

# Controls whether core dumps will append the PID to the core filename.
# Useful for debugging multi-threaded applications.
kernel.core_uses_pid = 1

net.ipv4.ip_always_defrag=1

----
My guess is that you don't have 'net.ipv4.ip_forward = 1' set so that
you forward packets.

echo "1" > /proc/sys/net/ipv4/ip_forward

generally gets that done in one command if that's the case

Craig