[Kamailio-Users] NAT traversal

Alex Balashov abalashov at evaristesys.com
Fri Feb 20 11:46:55 CET 2009


# nathelper

modparam("nathelper", "natping_interval", 30)
modparam("nathelper", "ping_nated_only", 1)
modparam("nathelper", "natping_processes", 3)
modparam("nathelper", "sipping_bflag", 3)
modparam("nathelper", "sipping_from", "sip:pinger at place")
modparam("nathelper", "sipping_method", "OPTIONS")


On initial INVITE received from user:

route[2} {
         if(nat_uac_test("1")) {
                 fix_nated_contact();
                 force_rport();
         }

         if(search("Content-Type: application/sdp") &&
		nat_uac_test("8")) {
                 fix_nated_sdp("10");
         }


         t_on_reply("1");

         if(!t_relay()) {
                 sl_reply_error();
                 exit;
         }
}

##
# Reply route for INVITE-related feedback and NAT fixups.

onreply_route[1] {
	# Technically, an SDP payload may be returned in
	# any non-100 1xx provisional message per RFC 3261,
	# not necessarily 180|183.  So, decide how standards-
	# compliant you want to be.

         if(t_check_status("200|180|183")) {

                 if(nat_uac_test("1"))
                         fix_nated_contact();


                 if(search("Content-Type: application/sdp")
				&& nat_uac_test("8")) {
                         fix_nated_sdp("10");
                 }
         }
}

On registration from user:

route[1} {
         if(nat_uac_test("1")) {
                 fix_nated_contact();
                 force_rport();
                 setbflag(3);
         }

         save("location");

}
	


BERGANZ François wrote:

> Have you an example?
> 
> 
> Cordialement,
> BERGANZ François
>  Pensez à l'Environnement, n'imprimez ce mail que si nécessaire.
> 
> 
> -----Message d'origine-----
> De : Alex Balashov [mailto:abalashov at evaristesys.com] 
> Envoyé : vendredi 20 février 2009 11:24
> À : Asim Riaz
> Cc : BERGANZ François; users at lists.kamailio.org
> Objet : Re: [Kamailio-Users] NAT traversal
> 
> I wouldn't use STUN.  It's an unnecessary complicated science project.
> 
> Unless the two media endpoints can't reach other, or the signaling 
> agents can't reach other due to asymmetric signaling or bad NAT devices 
> or stupidly implemented SIP ALGs or whatever, "nathelper" alone will do 
> just fine.  Just apply its fixups to your Contact URIs and SDP endpoints 
> and get perfectly good far-end NAT traversal.
> 
> I have deployed this many times for service providers and it works 
> great.   There will always be problems with some flaky end-user 
> equipment, but in general the benefits far outweigh the costs of 
> screwing around with STUN or anything of the sort.
> 


-- 
Alex Balashov
Evariste Systems
Web    : http://www.evaristesys.com/
Tel    : (+1) (678) 954-0670
Direct : (+1) (678) 954-0671
Mobile : (+1) (678) 237-1775




More information about the sr-users mailing list