Asterisk PBX server behind NAT (asterisk port forwarding)

Asterisk PBX server behind NAT (asterisk port forwarding)

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:

3 Replies to “Asterisk PBX server behind NAT (asterisk port forwarding)”

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

Leave a Reply

Your email address will not be published.