Two SIP listening ports for single Asterisk

From Kolmisoft Wiki
Jump to navigationJump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

There is no way to make a single instance of Asterisk listen on multiple ports. However, you can use an iptables REDIRECT to achieve the same functionality.

To redirect a single port with iptables:

 iptables -t nat -A PREROUTING -i eth0 -p udp --dport 5062 -j REDIRECT --to-ports 5060

This example redirects UPD port 5062 to port 5060, which effectively allows Asterisk to listen on both of them.

Do not forget to use the name of the network interface in this command yours, instead of eth0, if you have another.

Remember to save the rule so that it would survive a reboot:

/etc/init.d/iptables save

From: http://lists.digium.com/pipermail/asterisk-users/2008-November/221970.html

To check if rule is added:

iptables -L -t nat -n

If Virtual IP is used, then above will not work.

Use this rule instead:

  iptables -t nat -A PREROUTING -d 192.168.1.180 -p udp --dport 5062 -j  DNAT --to-destination 192.168.1.180:5060

replace 192.168.1.180 with Virtual IP.