/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-10.html (2525B)
Linux 2.4 NAT HOWTO: Destination NAT Onto the Same Network Next Previous Contents

10. Destination NAT Onto the Same Network

If you are doing port forwarding back onto the same network, you need to make sure that both future packets and reply packets pass through the NAT box (so they can be altered). The NAT code will now (since 2.4.0-test6), block the outgoing ICMP redirect which is produced when the NAT'ed packet heads out the same interface it came in on, but the receiving server will still try to reply directly to the client (which won't recognize the reply).

The classic case is that internal staff try to access your `public' web server, which is actually DNAT'ed from the public address (1.2.3.4) to an internal machine (192.168.1.1), like so:

# iptables -t nat -A PREROUTING -d 1.2.3.4 \
        -p tcp --dport 80 -j DNAT --to 192.168.1.1

One way is to run an internal DNS server which knows the real (internal) IP address of your public web site, and forward all other requests to an external DNS server. This means that the logging on your web server will show the internal IP addresses correctly.

The other way is to have the NAT box also map the source IP address to its own for these connections, fooling the server into replying through it. In this example, we would do the following (assuming the internal IP address of the NAT box is 192.168.1.250):

# iptables -t nat -A POSTROUTING -d 192.168.1.1 -s 192.168.1.0/24 \
        -p tcp --dport 80 -j SNAT --to 192.168.1.250

Because the PREROUTING rule gets run first, the packets will already be destined for the internal web server: we can tell which ones are internally sourced by the source IP addresses.


Next Previous Contents