port forwarding

Port Forwarding is configured on the router (machine making nat) and will forward connections originated from external clients to internal machine running asterisk.

If using Linux/Netfilter, run, on router:

  1. SET SIP SERVER INTERNAL IP (LAN)
SIP_SRV_LAN_IP=192.168.0.123

  1. FORWARDING
iptables -t nat -A PREROUTING -p udp -m multiport --dport 5060,10000:20000 -j DNAT --to-destination $SIP_SRV_LAN_IP

  1. ALLOW ASTERISK CONNECTIONS/REPLIES TO OUTSIDE (INTERNET)
iptables -A FORWARD -p udp -s $SIP_SRV_LAN_IP -j ACCEPT

  1. ALLOW FORWARDED CONNECTIONS/REPLIES TO INSIDE (LAN)
iptables -A FORWARD -p udp -m multiport --dport 5060,10000:20000 -d $SIP_SRV_LAN_IP -j ACCEPT


The range 10000:20000 is not mandatory, but in asterisk it is the default configuration. It can be checked (and altered if necessary) in the file rtp.conf, found generally in /etc/asterisk/rtp.conf.





Port Forwarding is configured on the router (machine making nat) and will forward connections originated from external clients to internal machine running asterisk.

If using Linux/Netfilter, run, on router:

  1. SET SIP SERVER INTERNAL IP (LAN)
SIP_SRV_LAN_IP=192.168.0.123

  1. FORWARDING
iptables -t nat -A PREROUTING -p udp -m multiport --dport 5060,10000:20000 -j DNAT --to-destination $SIP_SRV_LAN_IP

  1. ALLOW ASTERISK CONNECTIONS/REPLIES TO OUTSIDE (INTERNET)
iptables -A FORWARD -p udp -s $SIP_SRV_LAN_IP -j ACCEPT

  1. ALLOW FORWARDED CONNECTIONS/REPLIES TO INSIDE (LAN)
iptables -A FORWARD -p udp -m multiport --dport 5060,10000:20000 -d $SIP_SRV_LAN_IP -j ACCEPT


The range 10000:20000 is not mandatory, but in asterisk it is the default configuration. It can be checked (and altered if necessary) in the file rtp.conf, found generally in /etc/asterisk/rtp.conf.





Created by: tomlobato, Last modification: Fri 11 of Apr, 2008 (17:28 UTC) by bioia81
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+