Accessing Website with IP NAT Hairpinning

The term hairpinning comes from the fact that the traffic comes from one source into a router or similar devices, makes a U-turn and goes back the same way it came.

Visualize this and you see something that looks like a hairpin.

Hairpin NAT is a useful technique for accessing an internal server using a public IP. Since you are using a public IP to attempt to access a server in your network, the traffic will attempt to go out to the internet. In order to reach the server, the traffic will need to be redirected to the correct location.
The issue with this article is that you need to load a website or use curl to access the website on an internal IP that is set up as NAT to a public IP.

Scenario:

Server1 – Web Server. Has a public IP 214.44.55.44 and is behind a firewall with the private IP 10.0.0.12.

When you try and load the site on this server, it does not load.
Fix: Set up hosts file to point to the private IP.

Leave a Comment