iptables forwarding help

Romeo Theriault romeotheriault at gmail.com
Thu Jun 16 21:22:15 UTC 2011


On Thu, Jun 16, 2011 at 4:27 PM, Steven Buehler <steve at ibushost.com> wrote:
>
> I have been googling and researching iptables and forwarding all day and
> still can't figure this out.

Try something like this (untested):

# Make sure that this is set to 1 to enable forwarding.
cat /proc/sys/net/ipv4/ip_forward

# If it's not set, set it with:
echo 1 > /proc/sys/net/ipv4/ip_forward

# Setup your iptables rules that you need to enable the forwarding. In
this example, I'm just forwarding traffic from a specific ip to
another another ip.

iptables -A FORWARD -i eth0 -o eth1 -p tcp --dport 2222 -m state
--state NEW,ESTABLISHED,RELATED -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -i eth0 -d <eth0_ip> --dport 2222
-j DNAT --to <internal_server_ip>:22
iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE


Romeo




More information about the redhat-list mailing list