PJSIP: DNS Manager (dnsmgr) and Full Dynamic Hostname Support, Coming Soon!

PJSIP: DNS Manager (dnsmgr) and Full Dynamic Hostname Support, Coming Soon!

Recently there’s been discussion on chan_sip going away in the future which led to many comparisons between it and chan_pjsip. What does chan_pjsip do better? What is chan_pjsip missing? What does chan_sip do better? What does chan_pjsip have that chan_sip doesn’t?

Enter dnsmgr for PJSIP

One thing chan_sip has that chan_pjsip was lacking is the ability to handle dynamic IP addresses. This functionality is present in chan_sip via the externhost and externrefresh configuration options in sip.conf. From the sample configuration file:

“externhost = hostname[:port]” is similar to “externaddr” except
that the hostname is looked up every “externrefresh” seconds
(default 10s). This can be useful when your NAT device lets you choose
the port mapping, but the IP address is dynamic.
… Examples:

   externhost=foo.dyndns.net ; refreshed periodically
   externrefresh=180 ; change the refresh interval

If your Asterisk system is behind a dynamic IP address, chan_sip could be configured appropriately to handle any change to the IP address. The IP address could be changed by something external which Asterisk then uses to update its public IP address every refresh interval. A dynamic hostname can be specified, which is used to keep everything up to date.

For awhile, chan_pjsip did not have this functionality implemented. However, support has been added for dnsmgr (DNS manager) that allowed it to tackle this problem. Here’s what the dnsmgr.conf file looks like:

[general]
;enable=yes             ; enable creation of managed DNS lookups
                        ;   default is 'no'
;refreshinterval=1200   ; refresh managed DNS lookups every <n> seconds
                        ;   default is 300 (5 minutes)

In order to have your external address information automatically update you will need to enable dnsmgr and choose a refresh interval. The interval is how often dnsmgr will update the address information. While the default is 300 you can lower it if you want at the cost of more frequent DNS queries.

In pjsip.conf, you’ll need to set up a transport with the correct information. Here’s an example of a very basic configuration:

[example-transport]
type=transport
bind=0.0.0.0
protocol=tcp
local_net=192.0.2.0/24
external_media_address=foo.dyndns.net
external_signaling_address=foo.dyndns.net

[example-user]
type=endpoint
transport=example-transport
aors=example-user
auth=example-user
allow=!all,ulaw
context=examples

[example-user]
type=aor
max_contacts=10

[example-user]
type=auth
auth_type=userpass
username=example
password=secret

While full support for dnsmgr has not yet made it into a release it will be in the next set. As of this blog post that will be 13.19.0 and 15.2.0 so if you were holding off on building a PJSIP system due to a lack of support for dynamic IPs, check out those releases when they arrive and be prepared to give it a try!

For those that enjoy looking at the code more, here’s a link to the code review.

14 Responses

  1. This post identifies a single difference, it doesn’t answer all of the questions raised at the beginning. Is this the *only* difference? Surely there would be other differences in supported options and configurations as well?

  2. The only thing that PJSIP cannot do and it makes me conder it useless for massive business, is directmedia=yes. There is no way so far to make PJSIP emulate this feature of the old SIP channel, for it always proxys the media, and that is a killer.

    Am I wrong?

  3. Chris is correct, there is the “direct_media” option which is equivalent to chan_sip’s directmedia.

  4. Sure, there are other differences between the 2 channel drivers. After all, there is a reason we switched to chan_pjsip from chan_sip 🙂
    The main goal of this article wasn’t to focus on those differences, but rather to inform people who may not know that support has been added for dynamic IP addresses and discuss it. I guess we can blame my poor introduction for that!

  5. Hi all, my ISP did something last night that caused my IP address to change.

    First to be clear, I recently moved (@4months ago) all of my peers & trunks from SIP to PJSIP, all appears to be good.

    From the early days, I have ‘Externhost’ and ‘Externrefresh’ defined in my ‘sip.conf’ and more recently, I have enabled ‘DNS Manager’ via the ‘dnsmgr.conf’ file.

    With ‘sip show settings’, I was surprised to see my ‘old’ IP address was still there but on checking my trunk PJSIP registrations, all was good and a test incoming call was presented to the correct new IP address.

    My question is why does it state in the printout from ‘sip show settings’, my old IP address but more importantly, is there somewhere in the PJSIP stack that I can see what IP address my DNS has resolved to?

    Hope this makes sense 🙂 and thank you for your support

    Grüße,

    Kevyn

    on checking my server with

  6. PJSIP doesn’t use the sip.conf file. Are you sure you moved away from it, and also ensured that its configuration has the correct values?

  7. Hi Joshua,

    many thanks for your response and to answer your question re ‘Are you sure you moved away from it’, here is the printout results from two ‘sip show …’ commands:

    sip show registry
    Host dnsmgr Username Refresh State Reg.Time
    0 SIP registrations.

    sip show peers
    Name/username Host Dyn Forcerport Comedia ACL Port Status Description
    bogus xxx.xxx.xxx.xxx Yes Yes 5060 Unmonitored Bogus_Connection
    1 sip peers [Monitored: 0 online, 0 offline Unmonitored: 1 online, 0 offline]
    kevyn@DT001:~$

    so yes, all peers and trunks have been moved away from the sip protocol and are now all defined via the ‘pjsip’ stack.

    Here is the contents of my ‘dnsmgr.conf’ file:
    [general]
    enable = yes ; enable creation of managed DNS lookups default is ‘no’
    ;refreshinterval=1200 ; refresh managed DNS lookups every seconds default is 300 (5 minutes)

    and the transport section (in my pjsip.conf file):
    pjsip show transport transport_udp

    Transport:
    =============================================================
    Transport: transport_udp udp 0 0 0.0.0.0:wxyz

    ParameterName : ParameterValue
    ======================================================
    allow_reload : true
    async_operations : 1
    bind : 0.0.0.0:wxyz
    ca_list_file :
    ca_list_path :
    cert_file :
    cipher :
    cos : 0
    domain :
    external_media_address : mydnsname.com
    external_signaling_address : mydnsname.com
    external_signaling_port : 0
    local_net : xyz.xyz.xyz.xyz/255.255.255.0
    method : unspecified
    password :
    priv_key_file :
    protocol : udp
    require_client_cert : No
    symmetric_transport : false
    tos : 0
    verify_client : No
    verify_server : No
    websocket_write_timeout : 100

    And the next question is, is there an equivalent of ‘sip show settings’ that provides me with a printout similar to the following:
    Network Settings:
    —————————
    SIP address remapping: Enabled using externhost
    Externhost: mydnsname.com
    Externaddr: [my current public IP]
    Externrefresh: 30
    Localnet: xyz.xyz.xyz.xyz/255.255.255.0

    but for the PJSIP stack – I appreciate that I can already see from ‘pjsip show transport transport_udp’ printout my dns name under the ‘external_media/sig_address’ and my private IP address in ‘localnet’, but not the actual public IP address that my dns has (apparently) been resolved to as one can see from the ‘sip show’….’Externaddr: [my current public IP]’.

    And lastly (for the mo, that is :-)), am I right in saying that if I were to remove both the ‘externhost’ and ‘externrefresh’ entries (& cfg) from my ‘sip.conf’ file, that there would be no impact to my system?

    Many thanks for the support,

    Grüße,

    Kevyn

  8. Joshua C. Colp!!

    Why don’t you ‘people’ ever have the decency to reply!!!!!!!

    I feel I have asked a perfectly legitimate question based upon your statement:

    PJSIP doesn’t use the sip.conf file. Are you sure you moved away from it, and also ensured that its configuration has the correct values?

    the fact that I have confirmed that I have moved away and as ‘you’ don’t issue advice on configuration values anywhere else on an asterisk website!

    K

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

About the Author

What can we help you find?