PJSIP And NAT Behind A Dynamic IP Address

Home » Asterisk Users » PJSIP And NAT Behind A Dynamic IP Address
Asterisk Users 1 Comment

What should the PJSIP configuration be if your external IP address is dynamic, as is common with most home networks, and probably a lot of small business networks as well? The external_media_address and external_signaling_address transport settings are static. It would be possible to write a script that would detect the external IP address and rewrite the pjsip configuration file, but since you can’t change transports without a full restart of the server that doesn’t seem very friendly. Is the only alternative to rely on your firewall/router to fix up the address in the SDP?

One thought on - PJSIP And NAT Behind A Dynamic IP Address

  • If you review the current asterisk 12 sample pjsip config for extension
    6002 (viewable here:
    http://svnview.digium.com/svn/asterisk/branches/12/configs/pjsip.conf.sample), you will find it contains the correct settings for an endpoint behind NAT. Specifically note that you need rewrite_contact enabled so that the contact address is rewritten to match the inbound SIP registration, and also with rtp_symmetric enabled to do the same thing for RTP.

    Also be aware that you will have less problems by omitting the transport=
    line from the endpoint configuration altogether. It’s generally not required to define that the endpoint is restricted to using a specific transport, and doing so interferes with the automatic transport selection, possibly including the symmetric SIP operation.