/usr/share/doc/iptables/html
NameSizeModeActions
NAT-HOWTO-1.html11520644editdlrm
NAT-HOWTO-2.html43460644editdlrm
NAT-HOWTO-3.html14440644editdlrm
NAT-HOWTO-4.html44000644editdlrm
NAT-HOWTO-5.html51390644editdlrm
NAT-HOWTO-6.html83970644editdlrm
NAT-HOWTO-7.html13240644editdlrm
NAT-HOWTO-8.html11360644editdlrm
NAT-HOWTO-9.html20910644editdlrm
NAT-HOWTO-10.html25250644editdlrm
NAT-HOWTO-11.html9100644editdlrm
NAT-HOWTO.html26660644editdlrm
netfilter-extensions-HOWTO-1.html21020644editdlrm
netfilter-extensions-HOWTO-2.html78070644editdlrm
netfilter-extensions-HOWTO-3.html289690644editdlrm
netfilter-extensions-HOWTO-4.html125480644editdlrm
netfilter-extensions-HOWTO-5.html70410644editdlrm
netfilter-extensions-HOWTO-6.html112420644editdlrm
netfilter-extensions-HOWTO-7.html21880644editdlrm
netfilter-extensions-HOWTO-8.html10210644editdlrm
netfilter-extensions-HOWTO-9.html22220644editdlrm
netfilter-extensions-HOWTO.html72670644editdlrm
netfilter-hacking-HOWTO-1.html74740644editdlrm
netfilter-hacking-HOWTO-2.html17180644editdlrm
netfilter-hacking-HOWTO-3.html80380644editdlrm
netfilter-hacking-HOWTO-4.html533380644editdlrm
netfilter-hacking-HOWTO-5.html10560644editdlrm
netfilter-hacking-HOWTO-6.html30280644editdlrm
netfilter-hacking-HOWTO-7.html92880644editdlrm
netfilter-hacking-HOWTO-8.html52340644editdlrm
netfilter-hacking-HOWTO-9.html8350644editdlrm
netfilter-hacking-HOWTO.html38110644editdlrm
packet-filtering-HOWTO-1.html18910644editdlrm
packet-filtering-HOWTO-2.html15930644editdlrm
packet-filtering-HOWTO-3.html57750644editdlrm
packet-filtering-HOWTO-4.html21890644editdlrm
packet-filtering-HOWTO-5.html16440644editdlrm
packet-filtering-HOWTO-6.html35050644editdlrm
packet-filtering-HOWTO-7.html356160644editdlrm
packet-filtering-HOWTO-8.html14570644editdlrm
packet-filtering-HOWTO-9.html23330644editdlrm
packet-filtering-HOWTO-10.html25750644editdlrm
packet-filtering-HOWTO-11.html37420644editdlrm
packet-filtering-HOWTO.html28310644editdlrm
Edit: /usr/share/doc/iptables/html/NAT-HOWTO-4.html (4400B)
Linux 2.4 NAT HOWTO: Quick Translation From 2.0 and 2.2 Kernels Next Previous Contents

4. Quick Translation From 2.0 and 2.2 Kernels

Sorry to those of you still shell-shocked from the 2.0 (ipfwadm) to 2.2 (ipchains) transition. There's good and bad news.

Firstly, you can simply use ipchains and ipfwadm as before. To do this, you need to insmod the `ipchains.o' or `ipfwadm.o' kernel modules found in the latest netfilter distribution. These are mutually exclusive (you have been warned), and should not be combined with any other netfilter modules.

Once one of these modules is installed, you can use ipchains and ipfwadm as normal, with the following differences:

Hackers may also notice:

4.1 I just want masquerading! Help!

This is what most people want. If you have a dynamically allocated IP PPP dialup (if you don't know, this is you), you simply want to tell your box that all packets coming from your internal network should be made to look like they are coming from the PPP dialup box.

# Load the NAT module (this pulls in all the others).
modprobe iptable_nat

# In the NAT table (-t nat), Append a rule (-A) after routing
# (POSTROUTING) for all packets going out ppp0 (-o ppp0) which says to
# MASQUERADE the connection (-j MASQUERADE).
iptables -t nat -A POSTROUTING -o ppp0 -j MASQUERADE

# Turn on IP forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward

Note that you are not doing any packet filtering here: for that, see the Packet Filtering HOWTO: `Mixing NAT and Packet Filtering'.

4.2 What about ipmasqadm?

This is a much more niche user base, so I didn't worry about backward compatibility as much. You can simply use `iptables -t nat' to do port forwarding. So for example, in Linux 2.2 you might have done:

# Linux 2.2
# Forward TCP packets going to port 8080 on 1.2.3.4 to 192.168.1.1's port 80
ipmasqadm portfw -a -P tcp -L 1.2.3.4 8080 -R 192.168.1.1 80

Now you would do:

# Linux 2.4
# Append a rule before routing (-A PREROUTING) to the NAT table (-t nat) that
# TCP packets (-p tcp) going to 1.2.3.4 (-d 1.2.3.4) port 8080 (--dport 8080)
# have their destination mapped (-j DNAT) to 192.168.1.1, port 80
# (--to 192.168.1.1:80).
iptables -A PREROUTING -t nat -p tcp -d 1.2.3.4 --dport 8080 \
        -j DNAT --to 192.168.1.1:80


Next Previous Contents