[asterisk-dev] Wrong IP-address in SDP when on NAT in challenged Invite

Michael Maier m1278468 at mailbox.org
Wed May 5 14:40:07 CDT 2021


Hello!

When running asterisk on a system holding WAN and local IP, the IP used
for SDP in an outgoing call in the challenged INVITE is the local one
instead of the WAN IP when using a NATed transport instead of a
transport bound to the WAN IP.

The SDP in the initial INVITE is absolutely correct. But the following
Invite with the Auth header contains the wrong IP in SDP (the IP in the
SIP Contact and Via header are correct).

After digging in the code, I could see, that in
session_outgoing_nat_hook (res_pjsip_session.c) the nat rewrite is
stopped, because of an existing hook (I figured it out by some
additional debug outputs):

        /* SDP produced by us directly will never be multipart */
        if (!transport_state || hook || !tdata->msg->body ||

!ast_sip_is_content_type(&tdata->msg->body->content_type, "application",
"sdp") ||
                ast_strlen_zero(transport->external_media_address)) {
                return;
        }

The same behavior can be seen on the system which doesn't contain a
global IP - but the outgoing SDP IP is still correct here.

I'm wondering now, why the IP in the first case is wrong and in the
second case ok? What changes the IP? I couldn't find any point in
Asterisk. I'm suspecting pjsip changes something under the hood?

Would be glad if somebody could shed some light on this strange
behavior. Maybe an idea where to look at.


Thanks
Michael



More information about the asterisk-dev mailing list