External_media_address not working

Hello everyone,

I’m running into a strange issue where external_media_address is not being applied in the SDP.
Here’s my current PJSIP configuration:

PJSIP:

[transport-tcp-nat]
type=transport
protocol=tcp
bind=0.0.0.0
local_net=172.18.0.0/16
external_media_address= VM_IP
external_signaling_address=VM_IP

[SIP_USER]
type=endpoint
context=SIP_USER
disallow=all
allow=g722
allow=ulaw
auth=SIP_USER
aors=SIP_USER
set_var=PROJECT_ID=BOAL6716b4be0f
set_var=ORIGIN=phone-sip
transport=transport-tcp-nat
force_rport=yes
ice_support=yes
rewrite_contact=yes
direct_media=no
rtp_symmetric=yes

SIP LOG:

<--- Received SIP request (922 bytes) from TCP:176.223.0.0:60972 --->
UPDATE sip:VM_IP:5060;transport=TCP SIP/2.0
Via: SIP/2.0/TCP 192.168.1.141:60972;rport;branch=z9hG4bKPj03fd0474b24545348e73cfcf9e7a26ba;alias
Max-Forwards: 70
From: <sip:SIP_USER@VM_IP>;tag=f55db7369fd34e3eacec37a86df77bdb
To: <sip:1@VM_IP>;tag=58f2d668-9174-42fc-8390-809841c11712
Contact: <sip:SIP_USER@192.168.1.141:60972;transport=TCP;ob>
Call-ID: e9b66056955a45e5bb036305eda3ad37
CSeq: 5783 UPDATE
Supported: replaces, 100rel, timer, norefersub
Session-Expires: 1800;refresher=uac
Min-SE: 90
Content-Type: application/sdp
Content-Length:   320


<--- Transmitting SIP response (938 bytes) to TCP:176.223.0.0:60972 --->
SIP/2.0 200 OK
Via: SIP/2.0/TCP 192.168.1.141:60972;rport=60972;received=176.223.0.0;branch=z9hG4bKPj03fd0474b24545348e73cfcf9e7a26ba;alias
Call-ID: e9b66056955a45e5bb036305eda3ad37
From: <sip:SIP_USER@VM_IP>;tag=f55db7369fd34e3eacec37a86df77bdb
To: <sip:1@VM_IP>;tag=58f2d668-9174-42fc-8390-809841c11712
CSeq: 5783 UPDATE
Session-Expires: 1800;refresher=uac
Require: timer
Contact: <sip:VM_IP:5060;transport=TCP>
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, INFO, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub
Server: Asterisk PBX 20.15.2
Content-Type: application/sdp
Content-Length:   23

v=0
o=- 3979647768 3979647771 IN IP4 172.19.0.4
s=Asterisk
c=IN IP4 172.19.0.4
t=0 0
m=audio 10130 RTP/AVP 9 101

As you can see, Asterisk is still putting its internal IP (172.19.0.4) in the SDP instead of the external_media_address.

Interestingly, as soon as I remove the local_net line, audio starts working normally (it then correctly uses the external media address).

Any ideas what could be causing this?

Thank you.

[SOLVED]
Local_net: 172.18.0.0/16
Asterisk IP: 172.19.0.4
This missmatch subnet caused the problem.
Changed Local_net to 172.19.0.0/16 and it worked.