[OpenSIPS-Users] Is this "correct" rouing logic ?

Dovid Bender os-list at dovid.net
Tue Jan 31 16:22:10 CET 2012


Hi,

In Asterisk I need to have two peers so that I can differentiate between a
client behind NAT and a client that is not behind nat (to know if I should
proxy media or not). Here is my logic
No Nat: External IP -> 68.71.127.202:5999 -> 68.71.127.201:5060. The source
will be 68.71.127.202 so I can set in sip.conf that this peer is not behind
NAT
Nat:  External IP -> 68.71.127.202:5999 -> 68.71.127.203:5999 ->
68.71.127.201:5060. The source will be 68.71.127.203 so I can set in
sip.conf that this peer IS behind NAT.

Is my routing logic sound or is it severely flawed (excluding the lack of
security).

         ####### Global Parameters ######### 
           
         debug=6 
         log_stderror=no 
         log_facility=LOG_LOCAL0 
           
         fork=yes 
         children=4 
           
         disable_tcp=yes 
          
        #port=5999 
        listen=udp:68.71.127.202:5999 
        listen=udp:68.71.127.203:5999 
           
           
         ####### Modules Section ######## 
  	(Skipped module section so list would take number)           
           
           
           
         ####### Routing Logic ######## 
          
           
         # main request routing logic 
           
         route{ 
           
                 if (!mf_process_maxfwd_header("10")) { 
                         sl_send_reply("483","Too Many Hops"); 
                         exit; 
                 } 
           
                 xlog("Ri is >>> $Ri"); 
                 if($Ri == '68.71.127.203'){ 
                         sethostport("68.71.127.201:5060"); 
                         t_relay(); 
                         exit; 
                         } 
           
                 if(is_method("REGISTER")){ 
                         ## Send for now so we can call from X-Lite.. 
                         sl_send_reply("200","OK"); 
                         exit; 
                         ##exit; 
                         } 
           
                 force_rport(); 
                 if (nat_uac_test("19")) { 
                         xlog(">> Sending to 203 cause there is nat"); 
                         sethostport("68.71.127.203:5999"); 
                         record_route(); 
                         t_relay(); 
                         exit; 
                 } 
                 else{ 
                                 xlog(">> No nat so sending direct"); 
                                 sethostport("68.71.127.201:5060"); 
                                 record_route(); 
                                 t_relay(); 
                                 exit; 
           
                         } 
         } 


More information about the Users mailing list