- About VoIP
- What is VoIP and what it can do for you
- Introduction to VoIP (video)
- Why should you switch to VoIP services?
- Analog Telephony
- Digital Telephony
- What is SIP?
- How to start with VoIP telephony
- Web based VoIP
- How to choose a right VoIP provider?
- Wi-Fi network and VoIP
- VoIP Codecs
- Free sip account
- Confidential calls
- VPN: UDP or TCP?
- Mobile VoIP
- VoIP on your mobile
- Asterisk IP-PBX
- Who we are?
- How to start
- Free SIP account
- Configs
Asterisk SIP Media NAT
Synopsis: SIP signalling and voice media take independent IP routes. Furthermore the up and down streams are independently routed. The voice media is transported over RTP. One port is used for the upstream and another port, for downstream. Due to that mode of operation, the IP back route cannot be learned from the incoming route, as it was done for the SIP signaling.
By tradition these RTP ports are taken in sequence and many SIP Phone configuration software will only ask for one port (expecting that you will enter an even port value) and will silently configure the next odd port for the up stream.
Originally SIP was not designed for NAT
, so you need to read carefully your SIP phone documentation to know what will be done from your entered values.
SIP protocol has no concept of master /slave, we will use that side of the protocol to force the SIP Phone and Asterisk to select ports in two independent pre-defined ranges that we will smartly NAT. As stated before, SIP software will most likely silently assume the use of odd and even port. As this is outside of our control, so we will stupidly NAT both odd and even RTP ports to cover our back and be sure to route the right one. We will get the help of a STUN service to achieve an adequate IP routing.

Ports configuration on Asterisk side
Configure Asterisk to select ports known to be open for incoming traffic on the remote firewall. Any open port range of at least two ports will do. The AOL ports are very useful because they are likely to be open (port 5190-5193).
The range span will limit the number of simultaneous communication channels that you can achieve. In the reality of a home based Asterisk server this should not be an issue. In any case the low upstream bandwidth of an ADSL or cable modem services (typical 512 Kbps to 2 Mbit/s down) will not let you run more than a few phone calls in parallel. If you are lucky and you have good Internet connection (for example FFTB with true 30 or even 80 Mbit/s Ethernet as I do) you shouldn’t be limited.
The RTP port configuration is done by modifying the file /etc/asterisk/rtp.conf
[general]
rtpstart=5190
rtpend=5192
Note that Asterisk will silently use the port 5193 when rtpend is given as 5192.
by default you will see 10000 as rtpstart and 20000 as rtpend. On Cisco devices (like modern Cisco SRP and even old ATA-186 hardware) typical rtp range set as follows:
RTP Port Min = 16384 (by default)
RTP Port Max = 16482 (by default)
Minimum port number for RTP transmission and reception. The RTP Port Min and RTP Port Max parameters should define a range that contains at least 4 even number ports, such as 100–106. Maximum port number for RTP transmission and reception.
SIP phone / VoIP or GSM gateway / IP phone side:
Each SIP phone/device configuration is different. On the Gigaset 450 IP, the RTP ports can be configured by the Web interface. The use of random RTP port must be deactivated.
As we have no control of the mapping of the RTP port inside our domain and the public Internet and we cannot rely on a traffic in the other direction to establish the route (media opposite to signaling uses different paths for up- and down- streams) we must activate the STUN service which will be used by the SIP phone to publish port number that will be visible from the outside and will map with the configured port. STUN server uses by default the port 3478 which needs to be open. If you SIP phone does not support the STUN service, it will not work.
NAT configuration – Local Site
You simply need to configure your broadband gateway to redirect the traffic coming from the RTP port configured on your SIP phone on the A1 interface toward the same port on your A2 interface. Remember to forward the even and the odd port numbers.
Then open your firewall 1st and 2nd level for the same port range. If your Asterisk server is not set with your 2nd level firewall, you need to add a extra NAT rule to push the traffic to your Asterisk server IP address on your home LAN.
NAT configuration – Remote Site
You simply need to configure your broadband gateway to redirect the traffic coming from the RTP port configured in Asterisk to the same port on your SIP phone. Remember to forward the even and the odd port number. If you have followed my previous advise, the remote SIP phone should have a fixed IP address (not a DHCP allocated) what make the NAT stable over power cycle.
If you use a consumer gateway (e.g. Linksys) , activating a NAT for a port range opens the firewall at the same time.
Note : The proposed trick only works because we deactivate the SIP ReInvite functionality and force the SIP communication (Signaling and Media streams) to keep going through the Asterisk server. You must set ReInvite to NO.
canreinvite=no
in the sip.conf of the peers/users you working with
One Response to Asterisk SIP Media NAT
Leave a Reply Cancel reply
You must be logged in to post a comment.
Recent articles
- Plain explain: IP-phone
- Plain explain: What is SIP termination and what is SIP origination?
- US fixed VoIP market to see steady growth
- Save money with VoIP and unified communications
- IP telephony can help level the playing field for small businesses
- The loss of a landline means big change in communications
- Ubuntu (Linux) on your phone? Yes! And now officially!
- QoS For FaceTime, bandwidth requirements and Firewall config
- Merry Christmas and Happy New Year!
- How to Configure Axvoice Equipment?
- Cloud VoIP vs. on-premise VoIP: Choosing the right one for your business
- 26 terabits per second data transmission achieved
- A fully functional VoIP Client (SIP) finally released (free download)
- Fundamentals of SIP from Cisco :-)
- WebRTC from Google: making real-time communication free to implement
- What is VoIP termination
- Introduction to Voice over IP (VoIP)
- Linux: how to check OS version installed
- Hey!
- How to configure Internet tel. and SIP settings on Nokia phone (E52)
- TCP vs UDP – you must know this
- Google voice / Google talk and Asterisk configuration
- VoIP or IP Telephony?
- Asterisk 10.0.0-rc1 Now Available!
- SIP based VoIP behind NAT
- VoIP Quick start guide
- History: Kellogg Field Phone (World War I)
- Running VoIP via VPN (SSL) – voice quality
- Skype App directory
- G.711: u-law or a-law?
- Wi-Fi access point/router optimization for VoIP and other real time apps
- Agri-Cube grows mass quantities of vegetables in a one-car parking spot
- Quick Comparison of freeware IP-PBX platforms: Asterisk vs Open SER
- Microsoft enabling the ability to eavesdrop on VoIP conversations
- Nimbuzz growing even without Skype
- Skype protocol hack
- Call DSN number
- How to make your VoIP calls private and confidential
- Think on solutions: VoIP phone system
- Asterisk and Google Voice
- VoIP Codec: Payload size
- Nokia SIP settings
- The QoS Dilemma
- VoIP calls over satellite links
- VoIP for Facebook!
- VoIP client behind a VPN with DD-WRT
- Digital Telephony
- Analog Telephony
- Mobile VoIP – the future of mobile communications
- Sip on Android
VoIP SIP IP telephony tags
android Asterisk bandwidth bandwidth requirements best effort cellular codec delay encryption options facebook free calls g273 g726 g729 google gsm high latency How it works ilbc IPsec issues jitter listen to voip mobile Nimbuzz nokia order packet payload. g711 privacy protocol analyzer pstn QoS - Quality of Service QoS protocols real-time applications record voip calls satellite link sipdroid SIP protocol Skype speex TLS voice quality voip voip becomes socialQuick navigation
- Android (6)
- Apple (1)
- Asterisk (22)
- Cloud VoIP (1)
- FaceTime (1)
- Google Voice (6)
- History (2)
- IT news (2)
- Mobile VoIP (16)
- Symbian (1)
- Non VoIP news (2)
- Open source (10)
- Prioritization and traffic shaping (9)
- QoS – Quality of Service (11)
- SIP protocol (32)
- Cisco (2)
- SIP termination (2)
- SMS to email (1)
- Softphone VoIP (1)
- Ubuntu (1)
- Uncategorized (1)
- VoIP calls quality (24)
- VoIP industry news (4)
- VoIP over SSL VPN (1)
- VoIP over VPN (8)
- VoIP service (2)
- VoIP via VPN (1)
More to read on VoIP
- About
- About Mark Spencer
- Asterisk SIP Media NAT
- Browser-based VoIP: web page code to call over IP (to your VoIP account)
- Choosing the right provider
- Cisco ATA186 notes
- Free sip account
- Grandstream Budgetone configuration manual
- How to start with VoIP telephony
- Multiplexing RTP Data and Control Packets on a Single Port
- On-line payments
- VoIP Codecs
- VPN: UDP or TCP?
- What is VoIP and what it can do for you
- Why should you switch to VoIP services?
Blogroll
- Asterisk™: The Definitive Guide (new window) “Asterisk has been emblematic of the way that open source software has changed business—and changed the world”
- Blog Jon FreeSWITCH VOIP SIP Asterisk Linux Open Source
- Business.com Business.com is one of the Web’s largest directories for business products and services
- Ubuntu how-to www.ubuntuka.com Miscellaneous Ubuntu Tips, Tricks and Hints
Our Twitter – latest
- Introduction to Voice over IP (VoIP) - One important step into adopting VoIP is... voip-sip.org/introduction-t… 5 months ago
- How to configure Internet tel. and SIP... voip-sip.org/how-to-configu… 5 months ago
- Hey! - To all people who has an experience with Asterisk and Linux - quote of the day: "I have not failed.... voip-sip.org/hey/ 5 months ago
- What is VoIP termination - Many people keep asking me - what is VoIP Termination?... voip-sip.org/what-is-voip-t… 5 months ago
- How to configure Internet tel. and SIP... voip-sip.org/how-to-configu… 5 months ago


Cool article, thanks.