Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If two machines reside on the same LAN (a PC and a Webserver) why is it necessary to enable ‘NAT loopback’ on the router in order for the PC to access the website hosted on the webserver using the routers public IP (which port forwards on port 80 to the webserver)? This article on Dynamic DNS illustrates the setup perfectly

(In the example they are trying to access the webserver using the URL, for the purpose of my question thats not relevant, I'm just interested in accessing the webserver via the public IP, no URL involved)

The last sentence of the above article reads: “If they try to access the computer via the hostname, the NAT router will attempt to route this out its WAN interface and then back in. In most cases this will either fail or return the web interface for the router itself because the router doesn't understand what the user is trying to do.”

Can anyone offer a technical explanation as to why the router gets confused? What actually happens to the packets once they reach the router in this situation to confuse it?

Second question, if the router supports ‘NAT Loopback’ what is it that this feature changes in the routing to allow you to use the public IP?

share|improve this question

Here is an example. Some routers, like the Neufbox4 (a router provided by a french ISP) are running Linux. On these routers the program "iptables" is used to configure NAT behavior (iptables is some sort of swiss-army knife for Linux networking).

Suppose you have a webserver (port TCP 80) behind your router listening on LAN address and you add a port mapping (redirection) for it. This translates to something like this in iptables's terms:

iptables -t nat -A PREROUTING -i wan -p tcp --dport 80 -j DNAT --to-destination

This means "for every packet that comes in through the WAN interface directed at TCP port 80, send it to". Which is exactly what you want. All is fine... for now.

You have to understand that the IP address associated with the WAN interface of the router is your public Internet address. For example, if your Internet IP is, then the "wan" interface on the router has IP address

Now suppose you're trying to access your webserver from your LAN, say from your personal computer at address, using your own Internet address. So for example, you type "" in your browser.

What happens is that your computer will send a packet directed to, TCP port 80, on the LAN. The router will receive this packet. But it will not redirect it to Why? Because the iptables rule above only deals with packets coming in on the WAN interface, not from the LAN!

So what will happen then? Well, it depends on other networking rules on the router. Generally speaking one of two things will happen:

  • Either the router will see a packet directed at itself (remember, is one of the IP addresses of the router, so this is perfectly normal). On most routers there is a web server listening on port 80 for the administration interface. Consequently, this webserver will handle the packet, not the webserver on your LAN, and you get the administration interface instead of your website.

  • Or the router will drop the packet for some reason, simply because it doesn't know how to handle a packet directed at its WAN address on its LAN port.

Technically, the solution is very simple, it consists in a iptables rule of the form:

iptables -t nat -A PREROUTING -i lan -d -p tcp --dport 80 -j DNAT --to-destination

This means "for every packet that comes in through the LAN interface directed at TCP port 80, AND with a destination address of, send it to". This is what you would call "NAT loopback".

However, most router manufacturers are obviously not aware of the issue and didn't put this rule (or the equivalent in the router proprietary system) into their product...

share|improve this answer
Thank you for the swift response. Your answer summarizes the problem perfectly. As you have mentioned "...the router will drop the packet for some reason, simply because it doesn't know how to handle a packet directed at its WAN address on its LAN port." Something I would like to understand is the 'for some reason'. Why doesnt the router know how to handle the packet thats bound for itself. Technically, what actually happens in this event? – FitzRoy Sep 10 '09 at 23:46
I'm sorry, I have no idea as to why it drops the packet. I think the answer would depend on the model of the router and more precisely its operating system. – e-t172 Sep 11 '09 at 8:23

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.