[OpenSIPS-Users] 1-way audio (OpenSIPS + rtpproxy + NAT)

Matt Hamilton mistral9999 at hotmail.com
Mon Dec 5 20:37:07 CET 2011


I have phones (some behind NAT, some Public - on the same subnet as proxy server) connecting to Opensips server fronting an Asterisk cluster via rtpproxy (bridge mode) as seen below:


10.0.1.0/24 - external 
192.168.100.0/24 - internal
rtpproxy (bridge mode) started with '-l 10.0.1.75/192.168.100.75' option.




                                UAC2       
                               10.0.1.70   
                                   |
                                   |
UAC1--------------Firewall-----------------Opensips----------------Asterisk
10.0.2.50         10.0.1.12        |       10.0.1.75               192.168.100.128
                                   |       192.168.100.75          outboundproxy=192.168.100.75
                                   |
                                   |
                                UAC3
                                10.0.1.71




This is what I see:

- Calls between UAC2 and UAC3 are OK (both SIP and RTP). There is no NAT between them and Opensips.
- If UAC2 (or UAC3) initiates a call to UAC1, it is still OK (both SIP and RTP).
- If UAC1 initiates a call to UAC2, I get 1-way audio - only at UAC2 (no incoming audio at UAC1). 

Below is my opensips.cfg (only included the relevant code in modules, the route section is complete). Is there anything in there that seems suspicious? The SIP messages and rtpproxy translations look OK (but obvioulsy some are not). What should I be looking for in the SIP/RTP packets to debug this problem?

Thanks,
Matt
P.S. Firewall is open to all traffic. If I put Asterisk on the same subnet with Opensips (after fixing the IPs in cfg), the calls go thru OK both ways over NAT.


***************************************************************************
Dispatcher list has 192.168.100.128

listen=udp:10.0.1.75:5060
listen=udp:192.168.100.75:5060
alias=192.168.100.75:5060


modparam("dispatcher", "ds_ping_from", "sip:proxy at 192.168.100.75")
modparam("dispatcher", "ds_probing_sock", "udp:192.168.100.75:5060")
modparam("dispatcher", "force_dst", 1)   /* necessary?? */

modparam("rtpproxy", "rtpproxy_sock", "udp:127.0.0.1:7890")
modparam("nathelper", "natping_interval", 5)
modparam("nathelper", "ping_nated_only", 1)
modparam("nathelper", "sipping_bflag", 7)   /* use OPTIONS */
modparam("nathelper", "sipping_from", "sip:pinger at 10.0.1.75:5060")



route{
    if (!mf_process_maxfwd_header("10")) {
        sl_send_reply("483","Too Many Hops");
        exit;
    }

    
    if($si=="10.0.1.12"){        # replace with nat_uac_test("19") when public IPs are assigned
        fix_nated_contact();                                        
        search_append('Contact:.*sip:[^>[:cntrl:]]*', ';nat=yes');
        setflag(5);
    }
         else if (dst_ip == 192.168.100.75){
        setflag(11);
    }
    else if (dst_ip == 10.0.1.75) {
        setflag(12);
    } 

    
    # ----------- sequential request ------------------------------------------
          
    if (has_totag()) {      
        if (loose_route()) {
            if (is_method("BYE")) {
                #setflag(1); 
             } 
                   else if (is_method("INVITE")) {
                record_route();
             }
             route(1);
        } 
            else {
            if ( is_method("ACK") ) {
                if ( t_check_trans() ) {
                    t_relay();
                    exit;
                } 
                                else exit;
            }
            send_reply("404","Not here");
        }
        exit;
    }

    # ----------- the initial request ------------------------------------------
        
    if (is_method("CANCEL")){
        if (t_check_trans())
            t_relay();
        exit;
    }

    if (is_method("OPTIONS")) {
        t_relay();
        exit;
    }

    if (!is_method("REGISTER|MESSAGE"))
        record_route();


    if (is_method("INVITE")) {
        if (!ds_is_in_list("$si", "$sp")) {                 
            ds_select_dst("1", "7");
            force_send_socket(192.168.100.75);
            xlog("SENDING TO ASTERISK....External to Internal  RURI: $ru");
         }
        else {
              force_send_socket(10.0.1.75);
                  xlog("FROM ASTERISK....Internal to External  RURI: $ru");
                }
    }
    else if (is_method("REGISTER")) {
        ds_select_dst("1", "7");
        force_send_socket(192.168.100.75);
    }
    else if (is_method("SUBSCRIBE")) {
        ds_select_dst("1", "7");
        force_send_socket(192.168.100.75);
    }
    else {
        send_reply("405","Method Not Allowed");
        exit;
    }

    route(1);
}


#----------- ROUTES ------------------------------------------------------------

route[1] {
    if (subst_uri('/((sip:.*)||(sip:.*:.*));nat=yes/\1/')){
          setflag(11);          /* necessary */
        #setbflag(6);        # ??
    };

    if (isflagset(11)||isflagset(12)||isflagset(5)||isbflagset(6)) {
        route(nat_fixups);
    };

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


route[nat_fixups] {                                          
      if (is_method("BYE|CANCEL")) {
        unforce_rtp_proxy();
       } 
        else if (is_method("INVITE")){
        if(isflagset(5)||isbflagset(6)){
            rtpproxy_offer();  
        }
        else if(isflagset(11)){
            rtpproxy_offer("FAEI");
        }
        else if(isflagset(12)){
            rtpproxy_offer("FAIE");
        }
        else {
            xlog("NAT FIXUP RTP OFFER - not Found");        }
        
    };
     
    t_on_reply("2");  
}

onreply_route[2] {
      if ( is_method("INVITE") && 
           (isflagset(11) || isflagset(12) || isflagset(5) || isbflagset(6)) && 
           has_body("application/sdp") ){
            rtpproxy_answer();
    }
    if (isflagset(11) || isbflagset(6)) {                                              
        fix_nated_contact();
        search_append('Contact:.*sip:[^>[:cntrl:]]*', ';nat=yes');
    }
    exit;
}
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20111205/c1591275/attachment-0001.htm>


More information about the Users mailing list