PJSIP with a dynamic public ip address


I have an Asterisk 13 with can_sip running. My ISP gives me for a reconnection a new IP address.

Can I use PJSIP with those circumstances?


PJSIP does not currently have functionality to automatically update the public address (externhost / externrefresh). You would need to update this yourself or write a script to do it in the config file.

Okay, nevertheless it works even without the public IP. In the header it is written:

Only re-registration after an ip address change fails. I have compared the REGISTER from chan_sip with pjsip. chan_sip includes following line (pjsip does not add this line):

How can I add this line in pjsip REGISTER SIP header?

It is very unlikely that an ITSP would ever use Replaces, so this header should be irrelevant.

Okay, was just an idea.

PJSIP works very well, until the IP address changes. I can’t register my trunks any more.

res_pjsip_outbound_registration.c: Temporal response ‘500’ received from ‘sip:tel.t-online.de:5060’ on registration attempt to ‘sip:phonenumber@tel.t-online.de:5060’, retrying in '60’
res_pjsip_outbound_registration.c: Fatal response ‘403’ received from ‘sip:tel.t-online.de:5060’ on registration attempt to ‘sip:phonenumber@tel.t-online.de:5060’, stopping outbound registration[/quote]

If I shutdown Asterisk and wait for example 30 Minutes (PJSIP Expiration: 480 sec), Asterisk is able again register successfully.

No idea?

1 1/2 years have passed, and it seems pjsip still does not have any functionality equivalent to “externhost” in chan_sip.
Is there any specific reason, or is it just the spite of “professional” users who despise people who use their asterisk systems behind NAT on dynamic IPs?

I really can’t understand how such a simple yet important feature was still not implemented in PJSIP :frowning:

You would be incorrect. I implemented this recently[1]. In the next release external_media_address will resolve a provided hostname, and it uses dnsmgr underneath so if dnsmgr is configured to resolve things at a regular interval then it behaves the same as externhost. This applies to external_signaling_address as well.

As for why something does or doesn’t get implemented, you’re either dependent on yourself, Digium, or the open source community to implement things. We all have our own goals and limited resources or skills. That’s really what it comes down to. In this case I added support in my own spare time. If we had infinite time we could do more, but as it is we have to juggle things based on many different interests.

[1] https://gerrit.asterisk.org/#/c/6068/

Oh, thank you SO much for implementing this! Seems like PJSIP is indeed becoming capable of replacing chan_sip due to your efforts !

I’ll eagerly await Asterisk 14.7.0 and will spend the next weeks pressing “F5” on the download page every 5 minutes :slight_smile:

Hi Joshua, I have tested your implementation with the current git version of Asterisk 14 and the new function works great. An IP adress change is handled better than ever before.

Now I can completely switch to pjsip.

Thank you for your work on this topic!

1 Like