Asterisk behind NAT with dynamic IP (Proxy or STUN)

For chan_sip, they can be matched on IP address (type=peer), user part of From: header address (type=user), or either (type=friend). I think there is also an option to match on authorisation user, but I don’t know the details, and that clearly wouldn’t help you.

I imagine pjsip has something similar, but I think there are significant structural differences in this area.

I found out that my ITSP forbids to use the real public IP. I can use every IP address I want and it works properly (e.g. 10.0.0.1). Strange indeed!

So I use this configuration:

local_net=192.168.1.0/24
external_media_address=10.0.0.1
external_signaling_address=10.0.0.1

The IP in SDP is not changed to 10.0.0.1, what did I wong?

There was a bug which has been fixed[1] that could cause it not to go into the SDP, this will be in the next release.

[1] https://issues.asterisk.org/jira/browse/ASTERISK-27024

That will change and many people would want to do it.

There are plenty of people with dynamic public IP addresses, but who are still using chan_sip on their trunks.
With many moving over to pjsip in the mid term future, this topic will come up again.

I’m sure it will and that is of course taken into account when prioritizing things.

The problem is finally solved quite properly. Since Asterisk 14.7 and 13.8 you’re able to set a domain name as external_media_address and external_signaling_address, which dnsmgr resolves regularly. Thereby it’s possbile to run Asterisk behind NAT with a dynamic IP address!

Thanks to @Ustermann and especially to @jcolp ! See info in wiki: https://wiki.asterisk.org/wiki/display/AST/Configuring+res_pjsip+to+work+through+NAT?focusedCommentId=38273036#comment-38273036