Suppose you’ve set up an IP camera that you want to access from anywhere across the internet and have an external IP address or dynamic DNS address to use to access that camera. You’ve tested your setup when away from home and everything works well and as expected. You get home and use those very same details to access your camera and you get nothing, or worse, an error message.
You may be experiencing what's called NAT loopback. This quirk of router configuration often causes problems for new users and can be very frustrating. This post tries to explain why it happens and what you can do to get around it.
What is NAT loopback?
Your local network only understands 192.168.x.x addresses. For example, if you typed 192.168.0.2 into the browser, your network would understand that you’re trying to access your camera and send the information there. Whenever a different address is requested (such as an external IP address like 18.104.22.168 or a web address like mycam.mydomain.com) your router realises that this is not meant for your internal network and sends it out onto the internet.
However, if that external address (such as mycam.mydomain.com) actually points back to your home router this will be recognized and the information sent out is then passed back to your router. Now, either the router then routes this information back to the correct internal location (such as your IP camera) or it drops the incoming packets of data in a loop.
This loop is called NAT loopback and some routers allow it while others don't. If your router supports NAT loopback you won't see this as a problem since your camera will be accessible from all locations with the same address, but since you're reading this looking for a fix to why your IP camera is not accessible, your router probably does not support it.
Why does it happen?
Your camera and computer are most likely connected to a router (either wired up directly or via a wireless connection), which is then itself connected to the internet through your Internet Service Provider (ISP). Your router has two IP addresses: an internal one which is accessible only from your home network (for example 192.168.0.1) and one which is accessible from the internet. When accessing remotely you type in the external IP address of the router to access your camera since the internal one will never work externally.
NAT loopback happens when a device on your local network tries to access a device on that network via its public IP address. Instead of routing the traffic externally, NAT loopback aims to route the traffic via your local network, saving internet bandwidth and improving connection speeds.
One of the biggest problems with NAT loopback is that it’s often not obvious that everything is set up correctly. Some routers will display their own configuration page when such a request is made. Some will just not display anything while others are smart enough to recognize what you’re trying to do and will forward you to the right place.
How can I get around this?
There's no one fix to this. It’s all up to your router. If your router supports NAT loopback then great! Whenever you type in the address you’ll get through to your camera. If your router doesn’t support it, there’s not much you can do. You can, try a few methods to circumvent NAT loopback:
Using the right IP addresses
If your router does not allow NAT loopback your only option is to use your external address (mycam.mydomain.com) to access your IP camera when not at home, then use the local address (192.168.x.x) when you're at home. Set up a couple of bookmarks and this isn't really an issue, though it is frustrating.
Get a router that supports NAT loopback
The only other thing to do is to get a router which allows NAT loopback, though more often than not router specifications don't say whether it's supported or not, so if NAT loopback support is what you're after you'll need to ask the manufacturer.
Amend your hosts file
There is one other potential fix and that is to amend your local hosts file to point the external address to your internal camera. However, this is complicated so we'll handle it in another post later.