QUESTION How to make extensions auto-select correct transport/media_address without editing each one?

silimms

New Member
Joined
Feb 18, 2016
Messages
26
Reaction score
1
Environment:

IncrediblePBX (FreePBX) / Asterisk 22.11.0, chan_pjsip
Server with multiple network interfaces:
192.168.22.209 (eth0) — external-facing NIC, port forwarding for remote/roaming extensions + IAX2
192.168.23.209 (eth1) — internal VLAN, all internal phones live here (isolated, no internet access by design)
10.0.10.10 — SIP trunk Providers
All PJSIP UDP transports bound on port 7666 (per-IP)
SIP trunk Providers on 5060

Problem:

I have a multi-homed FreePBX / Asterisk (chan_pjsip) server. When an extension's transport is left empty, Asterisk auto-selects a transport and, in this multi-homed setup, often picks the wrong one. As a result the media_address ends up as the wrong interface IP — e.g. a phone registered from 192.168.23.69 gets media_address = 192.168.22.209.

What I've found works (but only per-extension):

I've found two ways to fix it, but each one has to be done per extension:

Option 1 — edit pjsip.endpoint_custom_post.conf:

[<extension number>](+)
media_address=192.168.23.9

Option 2 — modify the extension (GUI Advanced tab):

transport = 192.168.23.209-udp (the correct interface)
media_use_received_transport = yes

My question:

Is there a way to make this happen globally / automatically for all extensions, instead of editing every single extension (via the GUI Advanced tab or pjsip.endpoint_custom_post.conf)?
 
Yes, one line per transport, no per-extension edits. What you are fighting is how "Auto" behaves in 22.11: when the endpoint has no transport, a PBX-originated request (INVITE, OPTIONS) is sent on whichever UDP transport pjsip finds first, not on the one the phone registered through. Responses to the phone's own INVITEs already go back on the arrival transport, which is why it only "often" fails.


The global fix is the transport option symmetric_transport. With it set, every request that arrives on that transport gets the transport name stored in the contact URI as an x-ast-txp parameter at registration, and any later outgoing request to that contact uses the same transport as long as the endpoint's transport is empty and the contact host is an IP. FreePBX includes pjsip.transports_custom_post.conf immediately after its generated transports, so append it there once:


192.168.22.209-udp symmetric_transport=yes


192.168.23.209-udp symmetric_transport=yes


10.0.10.10-udp symmetric_transport=yes


Use your actual transport section names from pjsip show transports. Reload and make the phones re-register, since the tag is written at REGISTER time. pjsip show contacts should then show x-ast-txp=192.168.23.209-udp on the internal phones, with the endpoint's Transport still on Auto.


For the media address, leave it blank on every extension. Without media_address the SDP is first built with the host's default address and the outbound filter rewrites the c= line to the interface the OS routes to that phone, keeping port 7666; RTP is bound to 0.0.0.0 so it receives on any interface. Setting media_address per extension is what switches that rewrite off. Two things must be true for it to hold: Local Networks in SIP Settings lists all three subnets (192.168.22.0/24, 192.168.23.0/24, 10.0.10.0/24) so the External Address rewrite never applies to an internal destination, and the routing table sends each phone subnet out of the right interface, with static routes via eth1 if any internal phones sit behind the VLAN router rather than on 192.168.23.0/24.


Your Option 2 works because of the transport line; media_use_received_transport is about honouring the RTP profile from the offer, not interfaces, so drop it.


If after this an internal phone still gets c=192.168.22.209, post the startup line "Local IPv4 address determined to be" and the output of pjsip show transport 192.168.23.209-udp, and it becomes a two-line answer.
 

Forum statistics

Threads
26,807
Messages
175,209
Members
20,362
Latest member
Bxd4eva
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Back
Top