[SR-Users] nat_uac_test question

Kristian Kielhofner kris at kriskinc.com
Thu Jul 9 16:22:13 CEST 2015


Hello,

  I'm testing some basic flags with nat_uac_test. I have the following
(rudimentary) script:

route[NATDETECT] {
#!ifdef WITH_NAT
        if (has_body("application/sdp")) {
                if (nat_uac_test("18")) {
                        xlog("SCRIPT: SDP NAT Detected\n");
                        setflag(6);
                }
        } else {
                if (nat_uac_test("2")) {
                        xlog("SCRIPT: Other NAT Detected\n");
                        setflag(6);
                }
        }

        if (isflagset(6)) {
                xlog("SCRIPT: NAT detected\n");
                force_rport();
                if (is_method("REGISTER")) {
                        fix_nated_register();
                } else {
                        if(is_first_hop())
                                set_contact_alias();
                }
                setflag(FLT_NATS);
        }
#!endif
        return;
}

  When presented with this REGISTER message (ngrep output, so first
line is IP source address and port):

U 192.168.113.17:6060 -> 192.168.113.11:5060
REGISTER sip:192.168.113.11;transport=udp SIP/2.0.
Via: SIP/2.0/UDP 192.168.113.17:6060;branch=z9hG4bKOzvuzaIa;rport.
From: <sip:user_1 at 192.168.113.11>;tag=3F785909-559E7E9F0009321B-B5BFFB40.
To: <sip:user_1 at 192.168.113.11>.
CSeq: 10 REGISTER.
Call-ID: 1C193C6B-559E7E9F00093255-B5BFFB40.
Max-Forwards: 70.
User-Agent: FreeSWITCH.
Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE,
REGISTER, REFER, NOTIFY.
Supported: timer, path, replaces.
Contact: <sip:gw+sip0 at 10.40.47.190:5080;transport=udp;gw=sip0>;expires=3600.
Content-Length: 0.
.


U 192.168.113.11:5060 -> 192.168.113.17:6060
SIP/2.0 200 OK.
Via: SIP/2.0/UDP
192.168.113.17:6060;branch=z9hG4bKOzvuzaIa;rport=6060;received=192.168.113.17.
From: <sip:user_1 at 192.168.113.11>;tag=3F785909-559E7E9F0009321B-B5BFFB40.
To: <sip:user_1 at 192.168.113.11>;tag=b27e1a1d33761e85846fc98f5f3a7e58.1045.
CSeq: 10 REGISTER.
Call-ID: 1C193C6B-559E7E9F00093255-B5BFFB40.
Contact: <sip:gw+sip0 at 10.40.47.190:5080;transport=udp;gw=sip0>;expires=3600;received="sip:192.168.113.17:6060".
Server: Kamailio.
Content-Length: 0.
.

Log output:

Jul  9 10:00:41 kamailio /usr/sbin/kamailio[3886]: ERROR: <script>:
SCRIPT: Other NAT Detected
Jul  9 10:00:41 kamailio /usr/sbin/kamailio[3886]: ERROR: <script>:
SCRIPT: NAT detected


  Log output, the presence of the added "received" parameter in the
returned Contact, etc show that NAT was detected. However, the IP
source and port match the one presented in the Via header.

  What am I missing here?

Thanks!

-- 
Kristian Kielhofner



More information about the sr-users mailing list