<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#3333FF">
I have phones (some behind NAT) connecting to Opensips server an
Asterisk and an rtpproxy as seen below:<br>
<br>
rtpproxy started with<br>
ps -aux | grep rtpproxy<br>
root 15666 0.0 0.0 14472 920 ? Ssl Mar23 0:05
./rtpproxy -F -l 189.254.2.19 -s udp:* 7890 -d DBUG LOG_LOCAL3 <br>
<br>
<br>
<br>
UAC1 username =
100------------Firewall/router--------------------Opensips
1.7---------- RTP PROXY------------Asterisk 1.6<br>
192.168.1.10 192.168.1.1
65.254.63.212 189.254.2.19 190.61.201.89<br>
external ip dinamic 169.254.2.2<br>
<br>
<br>
- Calls between UAC are OK (both SIP and RTP).<br>
- Calls UAC for PSTN is OK.<br>
- Did numbers is received in Asterisk, and destination for UAC
registered in opensips, but no work audio .<br>
(EX User call cellphone for DID 54115368566, call is received in
asterisk, and destination for user 100, registered in opensips)<br>
<br>
<br>
<br>
<br>
loadmodule "db_mysql.so"<br>
loadmodule "signaling.so"<br>
loadmodule "sl.so"<br>
loadmodule "tm.so"<br>
loadmodule "rr.so"<br>
loadmodule "maxfwd.so"<br>
loadmodule "usrloc.so"<br>
loadmodule "registrar.so"<br>
loadmodule "textops.so"<br>
loadmodule "mi_fifo.so"<br>
loadmodule "uri.so"<br>
loadmodule "acc.so"<br>
loadmodule "dialog.so"<br>
loadmodule "load_balancer.so"<br>
loadmodule "nathelper.so"<br>
loadmodule "siptrace.so"<br>
loadmodule "rtpproxy.so"<br>
loadmodule "auth.so"<br>
loadmodule "auth_db.so"<br>
loadmodule "domain.so"<br>
<br>
modparam("load_balancer", "db_url",
"mysql://opensips:opensips@localhost/opensips")<br>
<br>
modparam("siptrace", "db_url",
"mysql://opensips:opensips@localhost/opensips")<br>
modparam("siptrace", "trace_flag", 22)<br>
modparam("siptrace", "trace_on", 1)<br>
modparam("siptrace", "enable_ack_trace", 1)<br>
<br>
<br>
modparam("rtpproxy", "rtpproxy_sock","udp:189.254.2.19:7890")<br>
<br>
<br>
modparam("dialog", "db_mode", 1)<br>
modparam("dialog", "db_url",
"mysql://opensips:opensips@localhost/opensips")<br>
<br>
<br>
modparam("nathelper", "natping_interval", 10)<br>
modparam("nathelper", "natping_processes", 3)<br>
modparam("nathelper", "natping_socket", "189.254.2.19:5006")<br>
modparam("nathelper", "received_avp", "$avp(42)")<br>
modparam("nathelper", "force_socket", "189.254.2.19:33333")<br>
modparam("nathelper", "sipping_from", <a class="moz-txt-link-rfc2396E" href="sip:pinger@65.254.63.212">"sip:pinger@65.254.63.212"</a>)<br>
modparam("nathelper", "sipping_method", "INFO")<br>
<br>
modparam("nathelper", "sipping_bflag", 7)<br>
<br>
modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")<br>
<br>
modparam("rr","enable_double_rr",1)<br>
modparam("rr","append_fromtag",1)<br>
<br>
modparam("registrar", "max_contacts", 10)<br>
<br>
modparam("usrloc", "db_mode", 2)<br>
<br>
modparam("usrloc",
"db_url","mysql://opensips:opensips@localhost/opensips")<br>
<br>
modparam("acc", "early_media", 1)<br>
modparam("acc", "report_cancels", 1)<br>
modparam("acc", "detect_direction", 0)<br>
modparam("acc", "failed_transaction_flag", 3)<br>
modparam("acc", "log_flag", 1)<br>
modparam("acc", "log_missed_flag", 2)<br>
modparam("acc", "db_flag", 1)<br>
modparam("acc", "db_missed_flag", 2)<br>
<br>
modparam("auth_db", "password_column", "password")<br>
modparam("auth_db", "password_column_2", "ha1b")<br>
modparam("auth_db", "calculate_ha1", 1)<br>
modparam("auth_db",
"db_url","mysql://opensips:opensips@localhost/opensips")<br>
modparam("auth_db", "load_credentials", "")<br>
modparam("auth_db", "skip_version_check", 1)<br>
<br>
modparam("domain",
"db_url","mysql://opensips:opensips@localhost/opensips")<br>
modparam("domain", "db_mode", 1) # Use caching<br>
<br>
modparam("auth_db|usrloc|uri", "use_domain", 0)<br>
<br>
route {<br>
if (!mf_process_maxfwd_header("256")) {<br>
if (method != "ACK") {<br>
sl_send_reply("483", "Too Many Hops");<br>
}<br>
return;<br>
}<br>
<br>
if (msg:len > max_len) {<br>
if (method != "ACK") {<br>
sl_send_reply("513", "Message Overflow");<br>
} <br>
return;<br>
}<br>
<br>
<br>
if (status == "482") { #loop detection<br>
xlog("L_INFO", "Webur: $mi $rm $fu -> $ru status 482 Loop
Detected\n");<br>
return;<br>
}<br>
<br>
if (!mf_process_maxfwd_header("3")) {<br>
sl_send_reply("483", "looping");<br>
exit;<br>
}<br>
<br>
<br>
if (has_totag()) {<br>
loose_route();<br>
t_relay();<br>
exit;<br>
}<br>
<br>
if (method == "INVITE") {<br>
route(3);<br>
return;<br>
} else<br>
if (method == "ACK") {<br>
route(9);<br>
return;<br>
} else<br>
if (method == "BYE" || method == "CANCEL") {<br>
route(5);<br>
return;<br>
} else<br>
if (method == "REGISTER" || method == "MESSAGE") {<br>
route(1);<br>
return;<br>
} else<br>
if (method == "PUBLISH" || method ==
"SUBSCRIBE") {<br>
sl_send_reply("200", "Understood");<br>
#route(2);<br>
return;<br>
} else<br>
if (method == "NOTIFY") {<br>
sl_send_reply("200", "Understood");<br>
return;<br>
} else<br>
if (method == "OPTIONS") {<br>
sl_send_reply("200", "Got it");<br>
return;<br>
}<br>
}<br>
<br>
route[1] {<br>
if (is_method("REGISTER")) {<br>
route(4);<br>
if (isflagset(5)) {<br>
record_route(";nat=yes");<br>
} else {<br>
record_route();<br>
}<br>
;<br>
<br>
if (!www_authorize("", "a2billing")) {<br>
www_challenge("", "0");<br>
}<br>
consume_credentials();<br>
<br>
$du = <a class="moz-txt-link-rfc2396E" href="sip:190.61.201.89:5060">"sip:190.61.201.89:5060"</a>;<br>
save("location");<br>
t_relay();<br>
exit;<br>
}<br>
}<br>
<br>
<br>
route[3] {<br>
<br>
xlog("L_INFO", "Place Holder");<br>
if (!has_totag()) {<br>
if (is_method("INVITE")) {<br>
trace_dialog();<br>
} else {<br>
#sip_trace();<br>
}<br>
}<br>
<br>
if (loose_route()) {<br>
if (!has_totag()) {<br>
xlog("L_INFO", "Initial loose-routing rejected - M=$rm
RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<br>
sl_send_reply("403", "Initial Loose-Routing Rejected");<br>
exit;<br>
}<br>
if (is_method("INVITE")) {<br>
<br>
route(5);<br>
}<br>
append_hf("P-hint: rr-enforced\r\n");<br>
route(6);<br>
}<br>
<br>
# NAT detection<br>
route(4);<br>
<br>
record_route();<br>
<br>
if ($rU = ~ "^[0-9]{5}$" || $rU = ~ "^[0-9]{3}$") {<br>
lookup("location");<br>
route(8);<br>
t_on_failure("1");<br>
exit;<br>
}<br>
<br>
route(10);<br>
return;<br>
}<br>
<br>
route[4] {<br>
if (is_method("INVITE") && has_totag()) {<br>
engage_rtp_proxy();<br>
}<br>
;<br>
force_rport();<br>
if (1) {<br>
if (nat_uac_test("19")) {<br>
xlog("L_DBG", "NAT detected1");<br>
if (method == "REGISTER") {<br>
fix_nated_register();<br>
} else {<br>
fix_nated_contact();<br>
fix_nated_sdp("1");<br>
<br>
<br>
xlog("L_INFO", "NAT detected2");<br>
}<br>
setflag(5);<br>
return;<br>
}<br>
}<br>
}<br>
<br>
route[5] {<br>
if (is_method("BYE|CANCEL")) {<br>
unforce_rtp_proxy();<br>
t_relay();<br>
exit;<br>
} else<br>
if (is_method("INVITE")) {<br>
if (has_body("application/sdp"))<br>
rtpproxy_offer("foc");<br>
t_on_failure("3");<br>
} else<br>
if (is_method("ASK")) {<br>
if (has_body("application/sdp"))<br>
rtpproxy_answer("foc");<br>
t_on_failure("3");<br>
}<br>
t_on_reply("3");<br>
}<br>
<br>
<br>
route[6] {<br>
if (subst_uri('/(<a class="moz-txt-link-freetext" href="sip:.*">sip:.*</a>);nat=yes/\1/')) {<br>
setbflag(0);<br>
}<br>
;<br>
xlog("L_INFO", "NAT detected");<br>
if (isflagset(5) || isbflagset(0)) {<br>
route(5);<br>
if (!t_relay()) {<br>
sl_reply_error();<br>
}<br>
;<br>
<br>
}<br>
<br>
}<br>
<br>
route[7] {<br>
if (is_method("BYE|CANCEL")) {<br>
unforce_rtp_proxy();<br>
drop();<br>
} else<br>
if (is_method("INVITE")) {<br>
if (has_body("application/sdp"))<br>
rtpproxy_offer("foc");<br>
t_on_failure("3");<br>
} else<br>
if (is_method("ASK")) {<br>
if (has_body("application/sdp"))<br>
rtpproxy_answer("foc");<br>
t_on_failure("3");<br>
}<br>
t_on_reply("3");<br>
exit;<br>
}<br>
<br>
route[8] {<br>
force_rport();<br>
<br>
if (has_body("application/sdp")) {<br>
rtpproxy_offer("foc");<br>
xlog("L_INFO", "NAT detected");<br>
t_on_failure("3");<br>
} else<br>
if (is_method("ASK")) {<br>
if (has_body("application/sdp"))<br>
fix_nated_sdp("1"); # Add direction=active to SDP<br>
rtpproxy_answer("foc");<br>
xlog("L_INFO", "NAT detected");<br>
<br>
}<br>
t_on_reply("3");<br>
<br>
if (!t_relay()) {<br>
sl_reply_error();<br>
route(13);<br>
exit;<br>
<br>
<br>
}<br>
<br>
<br>
}<br>
route[9] {<br>
setflag(4);<br>
force_rport();<br>
force_tcp_alias();<br>
rtpproxy_answer();<br>
return;<br>
}<br>
<br>
<br>
route[10] {<br>
<br>
load_balance("1", "pstn"); <br>
route(11);<br>
return;<br>
}<br>
<br>
route[11] {<br>
<br>
if ($retcode < 0) {<br>
sl_send_reply("500", "Service full");<br>
exit;<br>
}<br>
xlog("Selected Load Balance destination is: $rU@$du\n");<br>
<br>
route(4);<br>
<br>
if (!t_relay()) {<br>
sl_reply_error();<br>
route(13);<br>
}<br>
return;<br>
}<br>
<br>
<br>
branch_route[2] {<br>
xlog("L_INFO: new branch at $ru\n");<br>
}<br>
<br>
onreply_route[2] {<br>
xlog("L_INFO: incoming reply\n");<br>
force_rport();<br>
if (status = ~ "(183)|(2[0-9][0-9][0-9])" &&
has_body("application/sdp")) {<br>
if (nat_uac_test("19")) {<br>
log("L_INFO: Hem detectat NAT");<br>
setbflag(2); # flag for NAT<br>
# fix_nated_contact();<br>
fix_nated_sdp("11");<br>
rtpproxy_answer();<br>
}<br>
}<br>
}<br>
<br>
onreply_route[3] {<br>
if ((isflagset(5) || isbflagset(0)) && status = ~
"(183)|(2[0-9][0-9])" && has_body("application/sdp")) {<br>
if (rtpproxy_answer()) {<br>
log("L_INFO: rtpproxy_answer NAT");<br>
}<br>
}<br>
if (!subst_uri('/(<a class="moz-txt-link-freetext" href="sip:.*">sip:.*</a>);nat=yes/\1/')) {<br>
search_append('Contact:.*sip:[^>[:cntrl:]]*',
';nat=yes');<br>
}<br>
if (isbflagset(0)) {<br>
#fix_nated_contact();<br>
}<br>
exit;<br>
}<br>
failure_route[1] {<br>
if (t_was_cancelled()) {<br>
exit;<br>
}<br>
}<br>
<br>
failure_route[3] {<br>
if (isbflagset(0) || isflagset(5)) {<br>
unforce_rtp_proxy();<br>
}<br>
}<br>
<br>
<br>
<br>
<br>
Thanks, Magnus <br>
<br>
<br>
<br>
</body>
</html>