Dec
10
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

root@indiangnu.org:/etc/asterisk# cat rtp.conf
;
; RTP Configuration
;
[general]
;
; RTP start and RTP end configure start and end addresses
;

rtpstart=10000
rtpend=20000

root@indiangnu.org:/etc/asterisk#

*
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 192.168.1.150

2] Apply iptables rules for port forwarding

#Port forwarding for Asterisk
itables -I FORWARD -s 192.168.1.150 -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 192.168.1.150

#port forwarding for UDP

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

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

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

Thank you,

Arun Bagul

Similar Posts:

Be Sociable, Share!
(3) Comments    Read More   

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 http://www.linuxjournal.com/article/9399 if you’ve ran into any issues here, and you should be sorted. 😉


Post a Comment
Name:
Email:
Website:
Comments:


www.flickr.com
arunbagul's photos More of arunbagul's photos
Get Adobe Flash player
-->