Profile

Click to view full profile
Hi, I'm Veerapat Sriarunrungrueang, an expert in technology field, especially full stack web development and performance testing.This is my coding diary. I usually develop and keep code snippets or some tricks, and update to this diary when I have time. Nowadays, I've been giving counsel to many well-known firms in Thailand.
view more...

Tuesday, January 15, 2013

Double NAT - How to solve it?

Before I going to explain how to solve double NAT problem, I will introduce what is NAT first. Due to the number of IP addresses on internet is limited, NAT (Network Address Translation) was introduced. A router will use only one public IP address (Gateway), however, a network behind NAT is using private IP addresses, which is valid within the router network. To be able to access a network within NAT, port forwarding is required in order to bypass the public IP address with a specific port to a specific private IP address with specific port as well. This scenario represents a single level of NAT, having only one router cover all the entire network. But it often isn't simple like this.

Double NAT is a scenario where multiple routers on network do network address translation. The most common sample is a Cable or DSL modem is connected to a Wi-Fi router. NAT of both modem and router are enabled. Then, computers on the network are connected to the Wi-Fi router. In this scenario, even if port forwarding is setup on the Wi-Fi router, the computer will not be accessible from internet because the Wi-Fi doesn't have a public IP address. It has only a private IP address, which is given from the Cable/DSL modem. There are many solutions to solve this problem, however, there is no silver bullet. It depends on situation which one is suitable.

Possible Solutions: 

1. Setup PPPoE connection between the wireless router and modem 

This is the most robust solution, unfortunately not all ISPs provide enough information for this to be setup easily 

PPPoE can be usually setup in the wireless router's WAN settings. There are usually multiple options to configure the WAN connection of wireless router, amongst which are DHCP and PPPoE. DHCP is no good here, as it results in private IP address assigned to the WiFi router. PPPoE is better, because it bypasses the NAT in the modem, however it might need login and password information which the ISP might not provide.

2. Put the wireless router in bridged mode 

Bridged mode on wireless router means that NAT and DHCP functions on it will be disabled. Some router call it bridged mode, some simply allow you to disable NAT and DHCP. Unfortunately some WiFi routers simply don't support bridged mode at all. 

If you manage to switch router to bridged mode, all port forwarding needs to be configured on the modem (either automatically if it supports NAT-PMP, or manually).

3. Put the wireless router in modem's DMZ 

DMZ (demilitarized zone) is a common feature of router that allow to chose one client to which all traffic is forwarded. If your modem supports DMZ, this might be solution for you: 

1. Find out the WAN address of wireless router. For this you might need to log in to the WiFi router admin interface and look at the Status page (most router's have status pages which show relevant information about the WAN connection). 

2. Log in to the modem web administration interface, find the DMZ settings and put the WiFi router's IP WAN address there. 

Note that with this solution you will still get a double NAT warning in Air Video Server, but if the port forwarding on Wireless router is setup correctly, things should work.

4. Forward the port 45631/TCP in the modem to the router

This solution is similar to [3], except that instead of putting the WiFi router to modem's DMZ only one port is forwarded. 

1. Find out the WAN address of wireless router. For this you might need to log in to the WiFi router admin interface and look at the Status page (most router's have status pages which show relevant information about the WAN connection). 

2. Login in the modem web admin interface and configure port forwarding of port 45631 (protocol TCP) to the address from router's status page.

Note that with this solution you will still get a double NAT warning in Air Video Server.

From mentioned solutions, for me, I prefer to use the first two solutions because they are easy to setup, just setting either a DSL/Cable modem or Wi-Fi router to a bridged mode. The  two nested networks will become one. It is different only in setting DSL/Cable modem or router to a bridged mode is needed to use a Wi-Fi router connecting to ISP using PPPoE with username and password, but setting a Wi-Fi router to a bridged mode, the DSL/Cable modem or router must be able to set port forwarding, which in some routers there is only one direction from in to out, doesn't allow outside network coming in.

Reference: http://inmethod.com/forum/posts/list/908.page -> This thread helps me so much, thanks to him.

No comments:

Post a Comment