login | register
Wed 03 of Dec, 2008 [06:20 UTC]

voip-info.org

History

NAT and VOIP

Created by: jht2,Last modification on Sun 22 of Jun, 2008 [11:03 UTC] by lorenzo_voip_info

What is NAT?

NAT (Network Address Translation) is a technology most commonly used by firewalls and routers to allow multiple devices on a LAN with 'private' IP addresses to share a single public IP address. A private IP address is an address, which can only be addressed from within the LAN, but not from the Internet outside the LAN. In order to let a device with a private IP address communicate with other devices on the Internet, there needs to be a translation between private and public IP addresses at the point where the LAN connects to the Internet, that is within the firewall/router connecting the LAN to the Internet. Such a translation is commonly referred to as NAT (for Network Address Translation) and a router doing such translation is often called a NAT router or NAT firewall/router. Sometimes NAT is also called IP Masquerading. The passing of traffic through NAT is called NAT Traversal.

The way NAT works is in principle rather simple. When a device on the LAN initiates a connection with a device on the Internet, the device will send all traffic to the NAT router first. The NAT router then replaces the source address, which is the device's private address, with its own public address before passing the traffic to its destination on the Internet. When a response is received, the NAT router searches its translation tables to find the original source address of the packet from which the device on the LAN originally started the connection and thus passes the response to that device.

Unfortunately, when a connection is originated by a device on the Internet outside the LAN it is not clear which device on the LAN the connection is meant to be established with. In this case there needs to be some rule that tells the NAT router what to do with the incoming traffic, otherwise it will simply discard the traffic and no connection will be established. If the NAT router supports what is commonly referred to as a 'software DMZ' it can handle simple rules, such as "pass all incoming connection requests to the device with address 192.168.0.2". Another technique, called port forwarding allows the NAT router to pass incoming connection requests to different devices on the LAN depending on the type of connection (ie web or mail connection). However, if there are multiple devices on the LAN to which a certain type of connection from outside may need to be established, then neither a software DMZ nor port forwarding will be sufficient.

Sometimes people (those without network experience) have difficult to understand if their host is or not behind NAT, there is a website that can help you to get a clear answer (you need to have Java): (amibehindnat.com).

The Trouble with NAT and VOIP

In addition, the way in which conventional VoIP protocols are designed is also posing a problem to VoIP traffic passing through NAT. Conventional VoIP protocols only deal with the signalling of a telephone connection. The audio traffic is handled by another protocol and to make matters worse, the port on which the audio traffic is sent is random. The NAT router may be able to handle the signalling traffic, but it has no way of knowing that the audio traffic is related to the signalling and should hence be passed to the same device the signalling traffic is passed to. As a result, the audio traffic is not translated properly between the address spaces.

At first, for both the calling and the called party everything will appear just fine. The called party will see the calling party's Caller ID and the telephone will ring while the calling party will hear a ringing feedback tone at the other end. When the called party picks up the telephone, both the ringing and the associated ringing feedback tone at the other end will stop as one would expect. However, the calling party will not hear the called party (one way audio) and the called party may not hear the calling party either (no audio).

The issue of NAT Traversal is a major problem for the widespread deployment of VOIP. Yet, the issue is non-trivial and there are no simple solutions. In general terms there are two ways to deal with this problem:

  • avoid the problem altogether
  • working around the problem

Avoidance

By far the best way to deal with the issue of VoIP NAT Traversal is to avoid the cause of the problem in the first place:
  • Do not use NAT and obtain public IP addresses for all VoIP devices
  • If you cannot avoid NAT, use IP Tunneling between VoIP devices on different LANs
  • Use a public service. Eg sign up both sides to FWD and call from one to the other. Look at user authentication page for ways to control who has access to your internal lines
  • Use servers that implement http://tools.ietf.org/html/draft-ietf-sipping-nat-scenarios-06.txt. One of those is Yate

Workarounds

If you cannot avoid the problem, there are still several techniques available to work around the problem, none of them without their downsides. A white paper (NAT Traversal in SIP) explains some of the issues (at least as they relate to SIP signling) and discusses STUN- & ICE-based workarounds in more detail.
fridu has published a set of clarifications and a step by step solution to interconnect an Asterisk server and remote SIP phones over a dual NAT configuration. You will find it on fridu.org web site.

However, there are some simple workarounds available:
  • (Re) Configure your NAT device to provide (limited) VoIP support. The specific configuratios required depend on what is required by the signaling method used (e.g. SIP, H.323, etc.) and the number and type of devices inside your NAT, and are set using the specific user interface supplied by your NAT vendor.
    • For instance, to set up a single SIP phone inside a residential NAT:
      • Set the SIP phone up with a static IP address;
      • Set up two forwarding entries the "Port Forwarding" (or similar) configuration form on the NAT configuration interface, each of which cause the NAT device to forward all traffic destined for the designated range of port numbers to the fixed IP address of the SIP phone:
        • SIP signaling: Ports 5060 to 5070
        • RTP audio: Ports 8766 to 35000
    • For enterprise firewalls, many directly support SIP and H.323 forwarding to both Proxy/PBX devices as well as to/from VoIP phone endpoints
  • Use a VoIP Protocol that overloads HTTP in order to traverse NATs on normally-open IP ports, such as the open IAX protocol. (Caution: IP network protocol experts will point out that techniques such as this which use HTTP for purposes for which it was not intended frequently carry negative unintended side-effects.) A utility is available that enables Asterisk (win32) to work on the same box as ISA Server: SIPPF script.
  • IXC found an approach to enable NAT customers to be callable via h323. It's possible to test this 'know how' after registration. News release of new version is also available.
  • Linux kernel: Netfilter seems to have got a conntrack patch for sip/rtp nat/firewall traversal: Iptables sip conntrack
'different approaches for making sip devices work behind a dd-wrt router'
  • 'dd-wrt v23sp1voip' - upgrade your dd-wrt compatible router to dd-wrt v23sp1 (didn't test sp2 yet) VOIP version

This software release includes a special version of the ser (sip express router) software, which is able to act as an outbound proxy for sip devices (almost like a http proxy does for webbrowsers). ser and the second component rtpproxy take care of registering clients on the private network and forward all trafic between the sip service provider and the internal client (sip messages and rtp media streams).

This solution works fine for any device that has "outbound proxy" support as many ata (e.g. linksys-sipura spa 2001, grandstream budgetone etc.) do.

Just enter the ip adress and sip port (see dd-wrt administration interface for ip/port) of your dd-wrt router as outbound proxy in your phone's configuration screen. Restart the phone, and voila, you can talk. This works for an unlimited number of phones, as long as each phone uses a different sip username. Using the same sip username e.g. on a two analoge port sipura ata for both analog ports causes the second port to get registered to not work for incoming calls (not 100 % verified - please let me know if you tested it).

  • 'transparent proxy on dd-wrt/openwrt'
Me myself having trouble using sip devices without "outbound proxy" support behind my dd-wrt routers, I was searching for a more simple solution. My motivation was to have booth my asterisk box behind the router as well as my nokia e61 sip smartphone being able to register to out companies public sip server. This was not possible as both asterisk as well as the current nokia sip client don't support outbound proxy nor stun.

Having used transparent proxies for hhtp for a while, the question was, why not do the same for sip messages and the rtp media streams? Well, it's possible. I didn't actually figure it out using dd-wrt voip's built in ser/rtpproxy package (maybe it's possible too with them), but relied on the instructions i found for the software "sipproxd" which is luckily available for the mips based broadcom plattform (openwrt package).

What you basically need is:

- dd-wrt/openwrt (non voip firmeware version - tested with v23sp1) with jffs enabled (and enough spare memory - this solution does not work for 8mb and maybe also not for 16 mb broadcom based router models). I myself us a 32mb Linksys WRT54GS v1.1. You need JFFS as a filesystem to download, install and configure additional software packages useing ipkg.
- ssh/telnet access to your router
- the information available on http://siproxd.sourceforge.net/siproxd_guide/siproxd_guide_c6s4.html

First enable jffs and initialize ipkg (see other dd-wrt/openwrt faqs/howtos on how to do this in detail). Once you've done this log onto your router using telnet or better ssh (root/<yourwebadminpw>).

Then download the siproxd package using the command "ipkg install siproxd". Then follow the instructions on this manual page http://siproxd.sourceforge.net/siproxd_guide/siproxd_guide_c6s4.html

You've to create the config file using the editor "vi" on while being looged onto your router. Copying the Text from the webrowser to the console vi using putty can be quite a hassle as for some reason characters seem to move to other places whil in reality they are still on their old place in the textfile. To be sure, save the file often, then open it again to get a clean view and then copy the next part of the file.

Then start siproxd by calling it from the command line cd ... then ./siproxd -c <location of the config file you created e.g. /jffs/etc/siproxd.conf>.

Finally copy the iptables commands one after each other to the console. Then fire up your sip client with it being configures as if it had a public ip address (e.g. xxxxxx@sipgate.at etc.) and voila you can talk and you be reachable if someone is calling you.

Currently the solution is not 100 % stable, as my nokia e61 is registering with my public asterisk server sucessfully the first time, but not the second time once I lost wlan connectivity. I did not determine yet if it is a problem on the router/siproxd or if it was the due to nokia e61 software problems (I then had the www.one.at branded april/2006 software version in the phone. I have not tried it with the generic nokia 07/2006 version yet as I found an even better solution for my nokia which I'll describe below.

  • 'Mobile IPv4/Birdstep SmartRoaming'

The sipproxd solution works fine for clients within a fixed wlan/lan network. But what about poor me using my nokia outside my home/office network. It's nearly impossible to have all routers's equipped with siproxd transparent proxy solution.

After searching for a long time and having spent hours with Nokias incomplete SIP/Network Group Roaming implementation, I found a software supporting the Mobile IPv4 RFC on symbian operating systems. Great, what it basically does is having a client installed on your mobile phone, which makes a new connection available to all applications. It works like a vpn/tunnel. Thus once any network connection is available, the software signs up and creates a tunnel to Birdstel/Smartroaming and your phone gets a public IP from them.

Now it also takes care of you allways using the best connection, thus it's scanning for the wlan networks you've defined, and once you enter the office, it automatically sends all traffic via the wlan, or grps/umts vice versa when you leave the office. The applications are ALLWAYS ONLLINE and don't notice the connection change which is taking place in the background.

The best thing, there's no NAT, all applications are using the phones public ip via the tunnel. Thus your SIP client works flawlessly being able to register with my asterisk, sipgate and probably many other sip providers without any problem. Works like a charm.

The only drawback: after 1 month free trial, you've to pay a yearly fee of ~30 eur if you're using their Mobile IPv4 service. The say you can use the software (once you buy a licence) with other providers too. Too bad all open source software in regard to Mobile IPv4 is completely outdated and so to my knowledge no alternative option of being your own Mobile IPv4 Provider exists (apart from commercial software from hp/cisco etc.).

Some vendors offer information on the problem, and on how you can use their products to address the problem:



Free SIP NAT Solutions

  • Xtunnels Free NAT solution from Counterpath. Works with all Xlite and Eybeam softphones.


Other NAT Solutions

Some vendors offering NAT traversal 'solutions' for VOIP:








See also:


Comments

Comments Filter
222

333VPN for VoIP Blocking

by jenniferhan, Wednesday 12 of December, 2007 [06:09:32 UTC]
Somebody use VPN to solve the VoIP Blocking issue. But it seems not a good way to solve the voip blocking issue. Because VPN will take more bandwidth and will take effection on the Voice Quality

Currently I am using the VGCP, a new solution to solve the VoIP Blocking issue. Following is theirs website:
http://www.speed-voip.com/index-36.html

If any of you have interested, you may try to use it to solve your VoIP Blocking problems. Thanks.

Andy
andywong-01@hotmail.com

222

333Re: Broken link to pdf

by urbieta, Wednesday 27 of June, 2007 [17:10:19 UTC]
There is a backup at the internet archive though

http://web.archive.org/web/*/http://voip-itec.tamu.edu/files/reference/voip-nat.pdf


222

333warning

by ventora, Saturday 14 of April, 2007 [14:32:30 UTC]
i alwayes get the message at the asterisk consol
Apr 14 07:28:53 WARNING32646: channel.c:3645 ast_channel_bridge: Can't make SIP/ss79.xipx.com-082f9078 and SIP/196.219.50.76-082fe5b8 compatible
Apr 14 07:28:53 WARNING32646: res_features.c:1385 ast_bridge_call: Bridge failed on channels SIP/ss79.xipx.com-082f9078 and SIP/196.219.50.76-082fe5b8

222

333

by Sem, Friday 13 of January, 2006 [21:35:41 UTC]
hello
222

333Re: Just port forward your listening and RTP ports

by alvarocanivell, Thursday 12 of January, 2006 [17:21:45 UTC]
In my oppinion, any solution should try to avoid modifying the devices that give the client access to the internet (such as routers, firewalls, etc). In that way solutions are more flexible and versatile.

In that sense, using STUN could more suitable. Though not supported by all the clients, is sufficiently implemented and workable (as far as i have tested it...).
222

333Check out Edgewater Networks !

by , Friday 04 of February, 2005 [21:35:25 UTC]
(:cool:) They have a box that handles this very well. Their box provides NAT and firewall. Phones work very well behind their box on a NATted address.
http://www.edgewaternetworks.com
222

333Article is not correct

by , Wednesday 22 of December, 2004 [19:16:05 UTC]
NAT does not need to be avoided when doing SIP. With smart enough equipment and proper configuration it becomes trivial. Especially now when there are public STUN servers on the Internet.

There are 3 problems with doing SIP through NAT. Theres actually a 4th if you consider GW's trying to inherently do SPI (stateful packet inspection) on SIP, in the hopes of helping it do NAT traversal. The first problem is that device's try to Register with their private IP; or in point to point environment, putting their private IP as their VIA and Contact. The second problem with SIP through NAT is that GW/FW's are not going to allow inbound messages to your NATed device without an established pinhole (aka.. session). A session is created when an egress packet is sent from the NATed device to the Internet, the pinhole will allow the reply from the Internet to traverse the GW/FW and reach the NATed device. To keep a session up, which by the way are point to point, the NATed device behind the GW/FW must keep sending keep alive messages to keep the session/pinhole open. Sessions/pinholes have a life expectancy of about 30 secs to 5 minutes. So you wanna keep your keep alives at around 15-20 seconds... go with 10 and you should be good. The third problem was stated in the article, and thats the issues with RTP traffic traversing the NAT. I'll keep that one to myself as its a trade secret. ;)

222

333Incorrect Acronym for PAT

by , Tuesday 09 of November, 2004 [23:03:15 UTC]
PAT equal Port Address Translation as opposed to Network Address Translation.

PAT=many addresses hiding behind one address
NAT= 1:1 ratio of private and real addresses
222

333Just port forward your listening and RTP ports

by , Tuesday 02 of November, 2004 [01:04:13 UTC]
SIP and NAT isn't any bigger a deal than any other server application or p2p. Port forward the listening port and your range of RTP ports.

5060 and 10000 - 12000 (or however many RTP's you feel you need) # both UDP

In your sip.conf under general:

port = 5060 ; Port to bind to (probably don't change this)
bindaddr = 0.0.0.0 ; Address to bind to (all addresses on machine probably don't change this)
externip=xxx.xxx.xxx.xxx ; The IP that your ISP assigns you (change this)
localnet=192.168.1.0/255.255.255.0 ; your dhcp's local ip range and mask (maybe not required)
                                                    ; (change to what your DHCP uses..the mask part probably doesn't need to change though)
srvlookup=yes ; resolves IP's? (maybe not required)
nat=yes ; required
222

333Broken link to Cisco White Paper

by , Saturday 09 of October, 2004 [02:14:37 UTC]
Cisco has (re)moved its White Paper "VOIP traversal of NAT and firewall". I have asked them to replace it or advise me of its new location. Meanwhile, it can be found here:
http://voip-itec.tamu.edu/files/reference/voip-nat.pdf