Migrating to PJSIP with remote NAT

My asterisk server lies in a remote location through a company, its not behind a NAT, the ip address given to it is the internet address. However all my softphones that use it, both cell phone apps and computer apps, could be anywhere. I could be at work trying to make a call on my cell phone, at home making a call through my computer, or on the road using cellular network waiting to receive a call.

With sip.conf I just simply tell it to use NAT and everything simply works as expected. So how do I do this with PJSIP, I’ve searched for hours and it seems really complicated. Also most of the documentation seems to wrap around the server being behind a router, not the remote end.

On the official Asterisk documentation, at the very end, there was one small segment mentioning remote NAT. But it was very vague and I didn’t quite get it.

Can anyone help me?

Hi!

What you want should be in the pjsip.conf.sample file the example endpoint under the title:

You should read the help text for each option to understand them better. On the Asterisk CLI that is “config show help res_pjsip endpoint ”

IIRC these two res_pjsip options below basically equal nat=yes in for chan_sip:

However you also really need directmedia=no and ice_support could be useful if your endpoint supports ICE,STUN, TURN.

Despite all this, a lot still depends on the network at your remote endpoint and the firewall configuration there. Even with chan_sip, setting nat=yes would not automatically make any remote endpoint work. You are very lucky if it did! :smile: