PJSIP transport selection logic

Hi all,
I am running Asterisk 13.18.3 with PJSIP channel driver on a multi-homed server. Some enpoints are roaming between external and internal network, and they need to be operational regardless of the network they currently reside. However, it is not clear how to implement this scenario.

  1. If I specify transport in pjsip.conf, endpoints are operational from one network only (this is expected).
  2. If I omit transport, registration initially succeeds, but then Asterisk sends OPTIONS and INVITEs to the endpoint from a different IP, not respecting the IP recevied in the initial REGISTER message.
  3. If I specify transport as ‘’ binding IP address, I end up with the following error:
    Unable to retrieve PJSIP transport ''

My suggestion is that if transport is not specified, it should be selected based on the IP of an endpoint. However, it is not the case as you can see.

So, I have the following questions:

  1. What is the correct way to get SIP endpoints operational in a multi-homed environment?
  2. What is the transport selection logic if transport is not set explicitly? From here (3a), it is not clear how hashing mechanism works.
  3. What does transport mean (it is provided in sample configs and available in FreePBX) and why it is not working?

The transport option takes the name of the transport, if it’s not found then there is no transport by that name. You haven’t provided explicit configuration so I can’t say what it should be.

If is used then it is up to the underlying operating system to route accordingly, and we ask the operating system what interface the packet will go out on and update the message accordingly.

How things should be configured and used very much depends on the specific network layout and what it is like.

Transports in pjsip.conf:


local_net= - tunnel - LAN

Endpoints are roaming between LAN and tunnel.
If an endpoint is registered from LAN ( and transport IS NOT specified, subsequent OPTIONS message is sent from (which is strange).

Hostname> pjsip show transports

Transport:          udp      0      0
Transport:          udp      0      0

I’d suggest also providing actual traffic too showing the messages. - endpoint - Asterisk LAN IP - Asterisk tunnel IP

Transport config is provided above

Hostname> pjsip show endpoint 3202

 transport                          :  <empty>

Transport is not specified (set to Auto in FreePBX, provisioned to Asterisk correctly)

And if you use a wildcard

No, I mean create a single transport bound to

You can’t specify “” because that means “use a transport section named” and if you don’t have one nothing will happen.

Do you mean creating ONE transport only bound to and disabling all the other transports?

Yes, instead of creating individually bound ones.

Changed configuration as you advised:

[root@hostname]# asterisk -rx "pjsip show transports"
Transport:               udp      0      0
Objects found: 1
[root@hostname]# netstat -anp | grep 5060
udp        0      0  *                           15372/asterisk
[root@hostname]# asterisk -rx "pjsip show endpoint 3208" | grep -e 'transport'
 media_use_received_transport       : false
 transport                          :

Looks like the behaviour is correct now:

Continuing to monitor the behaviour

The above scenario works.

However, it is often needed to use a combination of static and dynamic endpoints.
For example, trunks should be bound to a particular interface, whereas clients should be dynamic due to the roaming between networks.

How to implement this scenario in PJSIP?

I don’t know if anyone has fully scoped out those scenarios, fixed any bugs that may exist, and figured out how it should be done so I can’t answer on specific configuration as to what to use that is known to work.


May be it is worth raising a ticket in JIRA with detailed explanation of the issue?
At least, the observed behavior in case when no transport is explicitly specified is obviously a bug.

You can do so, but I have no time frame on when such a thing would get looked into.