<div dir="ltr"><div><div>I'm working on setting up mid_registrar and it's mostly working but I have a problem with RTP being sent to the wrong address.<br><br></div>I'm trying to fix this by using fix_contact in my script but it doesn't appear to be rewriting the contact when the registrar is sent on to my Asterisk box.<br><br></div>I see the request from my phone to my proxy:<br><div><br>U 2018/03/19 12:04:54.650203 X.X.X.X:5060 -> <a href="http://192.168.69.159:5060">192.168.69.159:5060</a><br>REGISTER sip:<a href="http://pi.lzrd.net:5060">pi.lzrd.net:5060</a> SIP/2.0.<br>Via: SIP/2.0/UDP 172.16.52.76:5060;branch=z9hG4bK2864496306;rport.<br>From: "John Kiniston" <<a href="http://sip:7002kiniston@pi.lzrd.net:5060">sip:7002kiniston@pi.lzrd.net:5060</a>>;tag=2815321839.<br>To: "John Kiniston" <<a href="http://sip:7002kiniston@pi.lzrd.net:5060">sip:7002kiniston@pi.lzrd.net:5060</a>>.<br>Call-ID: <a href="mailto:0_2089376052@172.16.52.76">0_2089376052@172.16.52.76</a>.<br>CSeq: 1 REGISTER.<br>Contact: <<a href="http://sip:7002kiniston@172.16.52.76:5060">sip:7002kiniston@172.16.52.76:5060</a>>.<br>Allow: INVITE, INFO, PRACK, ACK, BYE, CANCEL, OPTIONS, NOTIFY, REGISTER, SUBSCRIBE, REFER, PUBLISH, UPDATE, MESSAGE.<br>Max-Forwards: 70.<br>User-Agent: Yealink SIP-T42S 66.81.0.110.<br>Expires: 0.<br>Allow-Events: talk,hold,conference,refer,check-sync.<br>Mac: 00:15:65:b4:d3:d3.<br>Line: 1.<br>Content-Length: 0.<br>.<br><br></div><div>And here is the request from my proxy to my PBX:<br></div><div><br>U 2018/03/19 12:04:54.808558 <a href="http://192.168.69.159:5060">192.168.69.159:5060</a> -> <a href="http://64.119.36.19:5060">64.119.36.19:5060</a><br>REGISTER sip:<a href="http://pi.lzrd.net">pi.lzrd.net</a> SIP/2.0.<br>Via: SIP/2.0/UDP 64.119.34.211:5060;branch=z9hG4bK0e8e.34dfaf97.0.<br>Via: SIP/2.0/UDP 172.16.52.76:5060;received=x.x.x.x;branch=z9hG4bK2864496306;rport=5060.<br>From: "John Kiniston" <<a href="http://sip:7002kiniston@pi.lzrd.net:5060">sip:7002kiniston@pi.lzrd.net:5060</a>>;tag=2815321839.<br>To: "John Kiniston" <<a href="http://sip:7002kiniston@pi.lzrd.net:5060">sip:7002kiniston@pi.lzrd.net:5060</a>>.<br>Call-ID: <a href="mailto:0_2089376052@172.16.52.76">0_2089376052@172.16.52.76</a>.<br>CSeq: 1 REGISTER.<br>Contact: <<a href="http://sip:7002kiniston@192.168.69.159:5060">sip:7002kiniston@192.168.69.159:5060</a>>.<br>Allow: INVITE, INFO, PRACK, ACK, BYE, CANCEL, OPTIONS, NOTIFY, REGISTER, SUBSCRIBE, REFER, PUBLISH, UPDATE, MESSAGE.<br>Max-Forwards: 69.<br>User-Agent: Yealink SIP-T42S 66.81.0.110.<br>Expires: 0.<br>Allow-Events: talk,hold,conference,refer,check-sync.<br>Mac: 00:15:65:b4:d3:d3.<br>Line: 1.<br>Content-Length: 0.<br>Path: <sip:64.119.34.211:5060;lr>.<br><br></div><div>Shouldn't the Contact be rewritten with the source IP of the request from the phone to X.X.X.X?<br><br><br>OpenSIPS$:ul show<br>Domain:: location table=512 records=1<br>        AOR:: 7002kiniston<br>                Contact:: sip:7002kiniston@X.X.X.X:5060 Q=<br>                        ContactID:: 2933602576022647686<br>                        Expires:: 3330<br>                        Callid:: <a href="mailto:0_2936163010@172.16.52.76">0_2936163010@172.16.52.76</a><br>                        Cseq:: 2<br>                        User-agent:: Yealink SIP-T42S 66.81.0.110<br>                        State:: CS_NEW<br>                        Flags:: 0<br>                        Cflags::<br>                        Socket:: udp:X.X.X.X:5060<br>                        Methods:: 16383<br><br></div><div><div><div><br></div><div>In my main script I have:<br><br>        if ($si == "X.X.X.X"){<br>                route(FromEndPoint);<br>        }<br><br></div><div><br>route[FromEndPoint]{<br>    route("nat_test_and_correct");<br>        if (is_method("INVITE")){<br>                if (is_registered("location","$fu")) {<br>                        route(outbound);<br>                } else {<br>                        t_reply("503","Authentication failed");<br>                }<br>        }<br>        if (is_method("SUBSCRIBE|NOTIFY|MESSAGE")){<br>                route(outbound);<br>        };<br>        if (is_method("REGISTER")) {<br>                route(register);<br>        }<br><br>}<br><br>route[register]{<br>        if (is_method("REGISTER")) {<br>                xlog("L_INFO","Saving location to mid_registrar");<br>                mid_registrar_save("location");<br>                switch ($retcode) {<br>                        case 1:<br>                                xlog("forwarding REGISTER to main registrar($$ci=$ci) $ru\n");<br>                                $ru = "sip:" + $td:$rp;<br>                                t_relay();<br>                                break;<br>                        case 2:<br>                                xlog("absorbing REGISTER! ($$ci=$ci)\n");<br>                                break;<br>                        default:<br>                                xlog("failed to save registration! ($$ci=$ci)\n");<br>                        }<br>                        exit;<br>        }<br>}<br><br><br>route[outbound]{<br>        t_relay();<br>        exit;<br>}<br><br>route[nat_test_and_correct] {<br>        if ((method=="REGISTER|SUBSCRIBE|INVITE") && !has_totag() && client_nat_test("3")) {<br>                nat_keepalive();<br>        }<br>        if (client_nat_test("3")) {<br>                force_rport();<br>                fix_contact();<br>        }<br>}<br><br><br>-- <br><div class="gmail_signature">A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects.<br>---Heinlein</div>
</div></div></div></div>