<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:2.0cm 42.5pt 2.0cm 3.0cm;}
div.Section1
        {page:Section1;}
/* List Definitions */
@list l0
        {mso-list-id:1391343390;
        mso-list-type:hybrid;
        mso-list-template-ids:976119412 68747279 68747289 68747291 68747279 68747289 68747291 68747279 68747289 68747291;}
@list l0:level1
        {mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=RU link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><span lang=EN-US>(Sorry for the previous partial email –
have troubles with the mail client).<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US>Hello.<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>After some playing with my first client
behind NAT it seems to me that NAT support in Asterisk is somewhat broken. At
least when nat= RFC3581.<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>If I understand the code properly, the idea
was that in order to detect NAT we are checking for the presence of rport in
incoming packets and if it is present, we are sort of switching to nat=route.<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US>The problem is that Asterisk still replies
packets to the address from Contact header even if there is ;rport so these
replies never get to the phone behind NAT. I originally filled the issue for
that: <a href="https://issues.asterisk.org/view.php?id=13823">https://issues.asterisk.org/view.php?id=13823</a>
The issue was later resolved but it seems that it is still not fixed and testing
shows there are more problems (below). Unfortunately it looks to me that you
guys at Digium do not run any tests with phones being behind NAT and nat=RFC.
(I think so because even simple REGISTER test should fail according to what I
saw).<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US>I tied fixing the code myself but only partially
succeeded. It required a person with really good understanding of what is going
on in chan_sip to do the proper fix. This is because these NAT related things
are spread all over across the code and I’m not really sure what causes
what.<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US>So what kind of use cases/problems I saw:<o:p></o:p></span></p>
<p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span
lang=EN-US><span style='mso-list:Ignore'>1.<span style='font:7.0pt "Times New Roman"'>
</span></span></span><![endif]><span lang=EN-US>“authentication required”
reply to REGISTER goes to wrong address. This I fixed myself.<o:p></o:p></span></p>
<p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span
lang=EN-US><span style='mso-list:Ignore'>2.<span style='font:7.0pt "Times New Roman"'>
</span></span></span><![endif]><span lang=EN-US>“authentication required”
reply to INVITE goes to wrong address. This I fixed myself although I’m
not proud of patch – it seems terribly wrong to me and a lot of
copy&paste.<o:p></o:p></span></p>
<p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span
lang=EN-US><span style='mso-list:Ignore'>3.<span style='font:7.0pt "Times New Roman"'>
</span></span></span><![endif]><span lang=EN-US>When making outbound call to
the registered phone, Asterisk sends SIP to the right address but it says “Transmitting
(no NAT)” in the console for some reason – so it considers the
phone not being behind the NAT despite the fact REGISTER came with ;rport and
the SIP_NAT_ROUTE was set because of it.<o:p></o:p></span></p>
<p class=MsoListParagraph style='text-indent:-18.0pt;mso-list:l0 level1 lfo1'><![if !supportLists]><span
lang=EN-US><span style='mso-list:Ignore'>4.<span style='font:7.0pt "Times New Roman"'>
</span></span></span><![endif]><span lang=EN-US>Because of #3 Asterisk also
starts sending RTP to wrong IP when making outbound call.<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US>Setting nat=yes seems to fix the issue but
my understanding is that everything should work with RFC3581 too. Otherwise I do
not understand purpose for this mode at all.<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US>Again, could someone with good
understanding of SIP channel architecture do a real test with NAT please? I believe
you will see everything yourself and won’t need any further explanation.<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US>Thanks.<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
</div>
</body>
</html>