PJSIP registers okay then any calls use External IP address in SIP "Contact= " field

Latest version of FreePBX, downloaded last week and all modules up to date. Not in office right now so can’t give you the exact version. will update on Monday. We are using PJSIP.

On one local network,, phones connect and register to FreePBX ( and call properly . Example, *43 Echo Test works fine and so does calling between phones. SIP headers have expected IP addresses of devices.

On another network, the same phones register properly. But *43 Echo Test provides one way audio and no audio on calls.

Looking at the SIP/SDP packets, I see that FreePBX/PJSIP adds a “Contact=” to the SIP header which is the external IP address to our network. The phones then attempt to reply to the external IP address which breaks the audio.

This definitely looks like a NAT problem BUT we have, and configured as local networks in Asterisk SIP Settings, Intrusion Detection and the Firewall.

On the extensions, we tried enabling and disabling “Rewrite Contacts” but no luck. Any ideas where to look?

A bad Contact header wouldn’t affect the (initial) audio, but it’s a good bet that the SDP body of the 200 OK sent by Asterisk also has the address, which would cause the phone to send media to the wrong address.

One possibility is that the pjsip driver is failing to handle multiple local networks properly. Setting Local Networks to may be a workaround (assuming that you don’t have anything in that range that is NATted relative to Asterisk). Restart (not just reload) Asterisk after making this change.

Ran into this today, all local networks were set properly, but pjsip extensions misbehaved until Asterisk was restarted.

Do you have reload set to yes?

1 Like

Not sure, but that is something to watch for testing in the future.

1 Like

Where is the setting “reload set to yes”?

It was tracing SIP that I noticed the incorrect Contact header pointing to the external IP address from Asterisk, after that point the local extension starting replying to the external IP address. Restarting Asterisk fixed the issue. Will look for the “set reload to yes” once I find out where the setting is… :slight_smile:

Settings, Asterisk SIP Settings, pjsip tab.

Just for the sake of interest, from the Asterisk CLI, I tried a “core reload” and it didn’t make a difference. Configured Asterisk SIP Settings - PJSIP Advanced settings and set the Allow Reload = Yes and resubmitted the extension then it worked fine after that. Strangely, there is no “pjsip reload” command in the Asterisk CLI.

Thanks for your help!

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.