Phone won’t register with Asterisk 11.5.x – NAT issue

I had a customer today that was struggling to get a phone to register on a server with Asterisk 11.5.1 installed, even though it would register OK on a server with Asterisk 11.3

The phone was behind a NAT firewall, with the Asterisk server on a public IP address.

Looking at the SIP packets they were coming from port 50758 –

--- SIP read from UDP:XX.XX.XX.XX:50758 ---

but when Asterisk replied it was sending the reply to port 5062 –

--- Transmitting (no NAT) to XX.XX.XX.XX:5062 ---

Now with either –

nat=yes

or –

nat=force_rport,comedia

on the extension Asterisk should have been replying to the port the traffic came from, but it wasn’t. Looks like this is caused by a currently unresolved bug in Asterisk – https://issues.asterisk.org/jira/browse/ASTERISK-22236

Something to check if you are having difficulty registering an extension. This will not affect all extensions as if a SIP ALG was changing to port in the SIP headers then Asterisk would be replying to the correct port.