Summary:ASTERISK-12684: r140417 broke sip nat interoperability
Reporter:mdu113 (mdu113)Labels:
Date Opened:2008-09-04 15:35:48Date Closed:2008-09-05 10:51:10
Versions:Frequency of
Environment:Attachments:( 0) 13424.patch
( 1) sip_trace.txt
Description:The scenario is very simple. I have 2 sip endpoints: xyz011101 and xyz010001, both on a private LAN ( behind the same nat device (cisco router) and asterisk on a public ip. This setup has been working for years, but after changes made in r140417, asterisk seems to ignore the source port the device was registered from and always sends requests to registration_ip:5060, which of course doesn't work.


Please see attached sip_trace.txt.
As you can see xyz010001 is registered from, but asterisk sends INVITEs to
If I revert that commit (140417) then everything's back to normal.
Comments:By: Russell Bryant (russell) 2008-09-05 07:18:18

FYI, since this change was done by you.

By: Mark Michelson (mmichelson) 2008-09-05 09:43:56

Ah yes, thanks for pointing to the revision. I see where my error in logic is. I'll make a patch to test ASAP.

By: Mark Michelson (mmichelson) 2008-09-05 09:52:13

I've uploaded 13424.patch for testing. The idea behind the commit which broke things for you was that if someone specifies a port when dialing, we should never ignore it. The problem is that I also made the inverse happen. If no port is specified when dialing a peer, then dial the standard SIP port, 5060.

The patch I have uploaded changes the behavior to be exactly what it should be. If a port is specified when dialing a peer, use that port. If no port is specified, then use the port the peer registered from.

By: mdu113 (mdu113) 2008-09-05 10:45:54

Yes, that patch fixes the problem. Thanks.

By: Mark Michelson (mmichelson) 2008-09-05 10:46:52

Excellent. I will get this committed then.

By: Digium Subversion (svnbot) 2008-09-05 10:51:07

Repository: asterisk
Revision: 141217

U   branches/1.4/channels/chan_sip.c

r141217 | mmichelson | 2008-09-05 10:51:07 -0500 (Fri, 05 Sep 2008) | 14 lines

Commit 140417 had a logic flaw in it which
caused port 5060 to always be used when dialing
a peer if no explicit port was specified. This
broke the behavior of implicitly using the port
from which the peer registered if no port is
specified. This commit fixes the logic flaw.

(closes issue ASTERISK-12684)
Reported by: mdu113
     13424.patch uploaded by putnopvut (license 60)
Tested by: mdu113