[asterisk-dev] SIP & NAT issues

Dmitry Andrianov Dmitry.Andrianov at dataart.com
Fri Mar 19 11:07:26 CDT 2010


(Sorry for the previous partial email - have troubles with the mail client).

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

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: https://issues.asterisk.org/view.php?id=13823 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).

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.

So what kind of use cases/problems I saw:

1.       "authentication required" reply to REGISTER goes to wrong address. This I fixed myself.

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

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

4.       Because of #3 Asterisk also starts sending RTP to wrong IP when making outbound call.

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.

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.

Thanks.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-dev/attachments/20100319/f9b732f8/attachment.htm 


More information about the asterisk-dev mailing list