HomeAboutMailing ListList Chatter /0/0

Adding second listening port to Asterisk

2021-10-07 by: lMike

To add a second listening port to an Asterisk system you have to do some tricks, because Asterisk will only listen to 1 port. IPTABLES to the rescue. You will want "iptables-persistent" if you don't have it. It's the last step because you will want it to save the rules you just made so they survive reboot. If using other iptables managers, you will want to do it their way.

On a bare/fresh Asterisk system running port 5060 or 5061:
#flush existing nat rules
iptables -t nat -F
#redirect 55060 to 5060
iptables -t nat -A PREROUTING -i eth0 -p udp --dport 55060 -j REDIRECT --to-ports 5060
iptables -t nat -A PREROUTING -i eth0 -p udp --dport 55061 -j REDIRECT --to-ports 5061
#show rules
iptables -L -t nat -n
#install iptables-persistent
apt install iptables-persistent
#to save and update rules anytime.
iptables-save >/etc/iptables/rules.v4
#reboot and test.