Published February 13th, 2003 by Jim O'Halloran

IPTables NAT

I had problems doing a simple port forward using iptables NAT today. I had everything in iptables setu up the same way as another machine which was doing similar forwards, but it just didn’t want to work.

In the end, I’d forgotten to…

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

To enable IP Forwarding. The Linux 2.4 NAT HOWTO doesn’t seem to mention this, and perhaps should.


6 Responses to “IPTables NAT”

Feed for this Entry
  1. 1

    phsieh Says

    Hi, Jim,

    I am planning to use MS Exchange 2000 server(on another server running win 2000 server). Also, all PC on the private network would like to connect to the internet through the Linux box. How do I set it up using iptables? Could you please explain? Thanks!

    phsieh

  2. 2

    Jim Says

    phsieh, see http://humboldt.kendle.com.au/weblog/archives/000120.html for an answer to your question.

    Jim.

  3. 3

    Herman Says

    Hi:

    I am trying to replace my cisco with a RH9 box. I have everything working except for nat.

    Eth0 is an ADSL line into the box.
    Eth1 is a connection to a catalyst switch feeding 11 work stations.

    I use the following script, and nothing works. Well, Squid works, we can surf the net, but that is about it. Any comments?

    =============================================

    iptables –flush
    iptables –table nat –flush
    iptables –delete-chain
    iptables –table nat –delete-chain

    iptables –table nat –append POSTROUTING –out-interface eth0 -j MASQUERADE
    iptables –append FORWARD –in-interface eth1 -j ACCEPT

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

  4. 4

    Francis S Victor Says

    iptables -t nat -A POSTROUTING -O ETH0 -J masquerade

  5. 5

    Shannon Wynter Says

    if you’ve denied everything by default you need the following

    iptables -I FORWARD -m state –state established,related -j ACCEPT

  6. 6

    Leif Madsen Says

    This is an old post, but it was the first link on Google, and was exactly what I’d forgotten too, lol. Thanks! :)

Leave a Reply

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>