Posted on 10-12-2007
Filed Under (Asterisk & VOIP) by Arun Bagul

If Your asterisk server is behind NAT then to access asterisk from outside world you need to use the port forwarding features of iptables in Linux.

Steps for asterisk Port forwarding

1] Check rtp.conf file in asterisk cat rtp.conf
; RTP Configuration
; RTP start and RTP end configure start and end addresses


In rtp.conf file rtpstart and rtpend variables defines which range of port is your asterisk server using for data transfer at real time it is 10000 to 20000 range.

*supose IP address of Asterisk server is

2] Apply iptables rules for port forwarding

#Port forwarding for Asterisk
itables -I FORWARD -s -p tcp –dport 5060 -j ACCEPT

#port forwarding for TCP
itables -A PREROUTING -t nat -i eth3 -p tcp -m tcp –dport 5060 -j DNAT –to-destination

#port forwarding for UDP

iptables -A PREROUTING -t nat -i eth3 -p udp -m udp –dport 5060 -j DNAT –to-destination

#port forwarding for RTP traffic
iptables -I FORWARD -s -p udp –dport 10000:20000 -j ACCEPT

iptables -A PREROUTING -t nat -i eth3 -p udp –dport 10000:20000 -j DNAT –to-destination

Thank you,

Arun Bagul

Similar Posts:

Be Sociable, Share!
(3) Comments   


Nishit Shah on 23 March, 2008 at 12:50 pm #

good Article

confused on 18 August, 2011 at 1:20 am #

hmm, i found this confusing.
is eth3 your internal, or external interface in this case?

confused on 18 August, 2011 at 3:13 am #

Well I managed to get it to work in the end. Have a look at if you’ve ran into any issues here, and you should be sorted. 😉

Post a Comment
arunbagul's photos More of arunbagul's photos
Get Adobe Flash player