<div dir="ltr">Hi,<br><br>I have a weird NAT traversal problem, I think is just a configuration issue with OpenSIPS. Outbound dialing works ok, inbound dialing works ok, but station to station calling does not work. <br><br>
Phone (behind NAT) <-----> OpenSIPS [nat traversal] <------> SIP-PBX<br><br>When the REGISTER comes into OpenSIPS, its doing NAT traversal and then passing it on to the SIP-PBX. Calls outbound and inbound work ok to a remote destination. The SIP-PBX is a production from Interactive Intelligence (i3). The problem appears to be when a new call originates from the SIP-PBX, it tries to send it directly to the Phone's public IP but does not have the NAT traversal information. <br>
<br>I think I may have configured OpenSIPS incorrectly, would appreciate someone with more of a clue about OpenSIPs than me to take a quick sanity check of the configuration. I swapped out the real IPs with private IPs for security reasons (<a href="http://10.13.140.245">10.13.140.245</a> => SIP-PBX, <a href="http://10.13.140.240">10.13.140.240</a> => SIP-PBX, <a href="http://10.14.210.97">10.14.210.97</a> => upstream sip trunk, <a href="http://10.14.210.99">10.14.210.99</a> => SIP-PBX). <br>
<br>route{<br><br> #<br> # -- 1 -- Request Validation<br> #<br> if (!mf_process_maxfwd_header("10")) {<br> sl_send_reply("483","Too Many Hops");<br> exit;<br> };<br>
<br> if (msg:len >= 2048 ) { <br> sl_send_reply("513", "Message too big");<br> exit;<br> };<br><br> # nat detection<br> route(5);<br><br> #<br> # -- 2 -- Routing Preprocessing<br>
#<br> ## Record-route all except Register<br> if (!method=="REGISTER") record_route();<br> <br> if (uri==myself) {<br> if (method=="REGISTER") {<br> if (isflagset(5)) {<br>
setflag(6);<br> }<br> save("location");<br># exit;<br> }<br> }<br><br> ##Loose_route packets<br> if (has_totag()) {<br> #sequential request withing a dialog should<br>
# take the path determined by record-routing<br> if (loose_route()) {<br> if(method=="BYE") {<br> #Account BYE transactions<br> setflag(2);<br> };<br>
#Check authentication of re-invites<br> route(1);<br> } else {<br> sl_send_reply("404","Not here");<br> }<br> exit;<br> }<br><br> #CANCEL processing<br>
if (is_method("CANCEL")) {<br> if (t_check_trans()) t_relay();<br> exit;<br> };<br><br> t_check_trans();<br><br> #<br> # -- 3 -- Determine Request Target<br> #<br> if (method=="REGISTER") {<br>
route(2);<br> } else {<br> route(3);<br> };<br>}<br><br>route[1] {<br> #<br> # -- 4 -- Forward request to target<br> #<br> ## Forward statefully<br> if (subst_uri('/(sip:.*);nat=yes/\1/')){<br>
setflag(6);<br> };<br><br> if (isflagset(5)||isflagset(6)) {<br> route(6);<br> }<br><br> if (!t_relay()) {<br> sl_reply_error();<br> };<br> exit;<br>}<br>
<br>route[2] {<br> rewritehostport("<a href="http://10.13.140.245">10.13.140.245</a>");<br> if (subst_uri('/(sip:.*);nat=yes/\1/')){<br> setflag(6);<br> };<br><br> if (isflagset(5)||isflagset(6)) {<br>
route(6);<br> }<br><br> if (!t_relay()) {<br> sl_reply_error();<br> };<br> exit;<br># sl_send_reply("401", "Forbidden");<br>}<br><br>route[3] {<br> ## Non-Register request handler<br>
if (method=="INVITE") {<br> # Account INVITE packets<br> setflag(2);<br> # Account Missed calls<br> setflag(3);<br> };<br><br> if (src_ip == <a href="http://10.13.140.240">10.13.140.240</a>) {<br>
<br> #Verify aliases, if found replace R-URI.<br><br> #Verify aliases, if found replace R-URI.<br> lookup("aliases");<br> append_hf("P-hint: route3-1 \r\n");<br> # -- Inbound to outbound<br>
route(11);<br> } else if (src_ip == <a href="http://10.13.140.99">10.13.140.99</a>) {<br> lookup("aliases");<br> append_hf("P-hint: route3-2 \r\n");<br> # -- Inbound to outbound<br>
route(11);<br> } else if (src_ip == <a href="http://10.13.140.245">10.13.140.245</a>) {<br> lookup("aliases");<br> append_hf("P-hint: route3-3 \r\n");<br> # -- Inbound to outbound<br>
route(11);<br> } else if (src_ip == <a href="http://10.14.210.97">10.14.210.97</a>) {<br> #From an external domain ->do not check credentials<br> append_hf("P-hint: route3-4 \r\n");<br>
#Verify aliases, if found replace R-URI.<br> lookup("aliases");<br> route(12);<br> } else {<br> append_hf("P-hint: route3-5 \r\n");<br> lookup("aliases");<br>
route(12);<br> };<br>}<br><br>route[4] {<br> # routing to the public network<br> record_route();<br> rewritehostport("<a href="http://10.14.210.97">10.14.210.97</a>");<br> route(1);<br>}<br>
<br>route[5]{<br> force_rport();<br> if (nat_uac_test("19")) {<br> if (method=="REGISTER") {<br> fix_nated_register();<br> } else {<br>
fix_nated_contact();<br> };<br> setflag(5);<br> };<br>}<br><br>route[6] {<br> if (is_method("BYE|CANCEL")) {<br> unforce_rtp_proxy();<br>
} else if (is_method("INVITE")){<br> force_rtp_proxy();<br> t_on_failure("1");<br> };<br> if (isflagset(5))<br> search_append('Contact:.*sip:[^>[:cntrl:]]*', ';nat=yes');<br>
t_on_reply("1");<br>}<br><br><br>route[10] {<br> #from an internal domain -> inbound<br> #Native SIP destinations are handled using the location table<br> #Gateway destinations are handled by regular expressions<br>
append_hf("P-hint: inbound->inbound \r\n");<br><br> if (uri=~"^sip:[2-9][0-9]{6}@") {<br> route(4);<br> exit;<br> };<br><br> if (uri=~"^sip:[2-9][1-9]{9}@") {<br>
route(4);<br> exit;<br> };<br><br> if (uri=~"^sip:1[2-9][1-9]{10}@") {<br> route(4);<br> exit;<br> };<br><br> if (uri=~"^sip:011[0-9]*@") {<br> route(4);<br>
exit;<br> };<br><br> if (!lookup("location")) {<br> sl_send_reply("404", "Not Found");<br> exit;<br> };<br> route(1);<br>}<br><br>route[11] {<br> # from an internal domain -> outbound<br>
# Simply route the call outbound using DNS search<br> append_hf("P-hint: inbound->outbound \r\n");<br> route(4);<br>}<br><br>route[12] {<br> # From an external domain -> inbound<br> # Verify aliases, if found replace R-URI.<br>
# lookup("aliases");<br># if (!lookup("location")) {<br># sl_send_reply("404", "Not Found");<br># exit;<br># };<br> record_route();<br> rewritehostport("<a href="http://10.13.140.245">10.13.140.245</a>");<br>
route(1);<br>}<br>route[13] {<br> #From an external domain outbound<br> #we are not accepting these calls<br> append_hf("P-hint: outbound->inbound \r\n");<br> sl_send_reply("403", "Forbidden");<br>
exit;<br>}<br><br><br>failure_route[1] {<br> if (isflagset(6) || isflagset(5)) {<br> unforce_rtp_proxy();<br> }<br>}<br><br>onreply_route[1] {<br> if ((isflagset(5) || isflagset(6)) && status=~"(183)|(2[0-9][0-9])") {<br>
force_rtp_proxy();<br> }<br> search_append('Contact:.*sip:[^>[:cntrl:]]*', ';nat=yes');<br><br> if (isflagset(6)) {<br> fix_nated_contact();<br> }<br>
exit;<br>}<br><br><br><br></div>