iptables forwarding help

Steven Buehler steve at ibushost.com
Fri Jun 17 00:38:41 UTC 2011



> -----Original Message-----
> From: redhat-list-bounces at redhat.com [mailto:redhat-list-
> bounces at redhat.com] On Behalf Of Romeo Theriault
> Sent: Thursday, June 16, 2011 4:22 PM
> To: General Red Hat Linux discussion list
> Subject: Re: iptables forwarding help
> 
> 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
> 

Thanks, it was the last line that I was missing
iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE





More information about the redhat-list mailing list