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

Joshua C. Colp jcolp at sangoma.com
Thu May 6 13:21:06 CDT 2021


On Wed, May 5, 2021 at 4:40 PM Michael Maier <m1278468 at mailbox.org> wrote:

> 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.
>

The only thing that comes to mind is the code in
res/res_pjsip/pjsip_message_filter.c that alters the SDP in some scenario
to update it for the transport the message is going out on.

-- 
Joshua C. Colp
Asterisk Technical Lead
Sangoma Technologies
Check us out at www.sangoma.com and www.asterisk.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20210506/e3a4b4bb/attachment.html>


More information about the asterisk-dev mailing list