Hello,
maybe this link helps:
http://voip-info.org/wiki/view/OpenSER+And+Mediaproxy
Cheers, Daniel
On 10/18/06 19:04, Marnus van Niekerk wrote:
Hi,
I am trying to set up openser with mediaproxy (at xx.xx.xx.133) to route calls from UA behind NAT to asterisk as voicemail (at xx.xx.xx.134) and PSTN gateways (at xx.xx.xx.32)
I can see in the SDP payload that the RTP is being sent from asterisk to mediaproxy, but in sessions.py it shows the private ip not the public one and I have one way audio.
Can anybody help please.
opnser.cfg below.
Marnus
--
debug=3 # debug level (cmd line: -dddddddddd) fork=yes log_stderror=no # (cmd line: -E) log_facility=LOG_LOCAL6
check_via=no # (cmd. line: -v) dns=no # (cmd. line: -r) rev_dns=no # (cmd. line: -R) port=5060 children=4 fifo="/tmp/openser_fifo"
# ------------------ module loading ---------------------------------- loadmodule "/usr/local/lib/openser/modules/mysql.so" loadmodule "/usr/local/lib/openser/modules/sl.so" loadmodule "/usr/local/lib/openser/modules/tm.so" loadmodule "/usr/local/lib/openser/modules/rr.so" loadmodule "/usr/local/lib/openser/modules/maxfwd.so" loadmodule "/usr/local/lib/openser/modules/usrloc.so" loadmodule "/usr/local/lib/openser/modules/registrar.so" loadmodule "/usr/local/lib/openser/modules/textops.so" loadmodule "/usr/local/lib/openser/modules/uri_db.so" loadmodule "/usr/local/lib/openser/modules/domain.so" loadmodule "/usr/local/lib/openser/modules/mediaproxy.so" loadmodule "/usr/local/lib/openser/modules/nathelper.so"
# Logging loadmodule "/usr/local/lib/openser/modules/xlog.so"
loadmodule "/usr/local/lib/openser/modules/auth.so" loadmodule "/usr/local/lib/openser/modules/auth_db.so"
# ----------------- setting module-specific parameters ---------------
# -- usrloc params -- modparam("usrloc", "db_mode", 0)
modparam("usrloc", "db_mode", 2)
modparam("auth_db", "calculate_ha1", yes) modparam("auth_db", "password_column", "password")
modparam("rr", "enable_full_lr", 1)
#tm timeout for voicemail params modparam("tm", "fr_timer", 3) modparam("tm", "fr_inv_timer", 35) modparam("tm", "noisy_ctimer", 1)
# parms for NAT/mediaproxy modparam("nathelper", "rtpproxy_disable", 1) modparam("nathelper", "natping_interval", 0) modparam("mediaproxy", "natping_interval", 30) modparam("mediaproxy", "mediaproxy_socket", "/var/run/mediaproxy.sock") modparam("mediaproxy", "sip_asymmetrics", "/usr/local/etc/openser/sip-clients") modparam("mediaproxy", "rtp_asymmetrics", "/usr/local/etc/openser/rtp-clients") modparam("registrar", "nat_flag", 6)
# ------------------------- request routing logic -------------------
# main routing logic route { #check for old messages: could mean a problem with the DNS entries or some other loop-causer... if (!mf_process_maxfwd_header("10")) { xlog("L_WARN", "WARNING: Too many hops\n"); sl_send_reply("483", "Too many hops, forward count exceeded limit\n"); return; };
#check for extremely large messages; we don't need a sip dos
attack if (msg:len >= 2048) { xlog("L_WARN", "WARNING: Message too large, &>= 2048 bytes\n"); sl_send_reply("513", "Message too large, exceeded limit\n"); return; };
# Track what is happening xlog("L_INFO", "SIP Request: method [$rm] from [$fu] to [$tu]\n"); #record everything besides registers and acks if(method!="REGISTER" && method!="ACK") { setflag(1); }; # Record Route Section if (method=="INVITE" && client_nat_test("3")) { record_route_preset("xx.xx.xx.133:5060;nat=yes"); } else if (method!="REGISTER") { record_route(); } # Call tear down section if (method=="BYE" || method=="CANCEL") { end_media_session(); } #do not send to voicemail if BYE or CANCEL #is used to end call before user pickup or timeout if(method=="CANCEL" || method=="BYE") { setflag(10); }; #grant route if route headers already present if (loose_route()) { # May need client_nat_test & use_media_proxy here... route(1); return; }; #Always require authentication, which could result in a PSTN if (method=="REGISTER") { if (!search("^Contact:[ ]*\*") && client_nat_test("7")) { setflag(6); fix_nated_register(); force_rport(); }; if(!www_authorize("domain.tld", "subscriber")) { www_challenge("domain.tld", "0"); return; } else { if (!check_to()) { sl_send_reply("401", "Unauthorized"); return; }; #Save into user database, used below when
checking if user is available xlog("L_INFO", "REGISTER: User $fu Authenticated Correctly\n"); save("location"); return; }; };
if (method=="INVITE") { if (client_nat_test("3")) { setflag(7); force_rport(); fix_nated_contact(); }; if(uri=~"sip:\*86@.*") { #authorize if a call is going to VM if(!proxy_authorize("domain.tld", "subscriber")) { proxy_challenge("domain.tld", "0"); return; }; xlog("L_INFO", "CALL: Call from $fu to check
voicemail\n"); rewritehostport("vm.domain.tld:5060"); } else { if (does_uri_exist()) { #Call is to sip client, so do nothing but route xlog("L_INFO", "CALL: Sip client\n"); if (!lookup("location")) { sl_send_reply("404", "Not Found"); xlog("L_ERROR", "ERROR: User $tu Not Found\n"); return; }; } else { #authorize if a call is going to PSTN if(!proxy_authorize("domain.tld", "subscriber")) { proxy_challenge("domain.tld", "0"); return; };
#Call destination is PSTN, so send it
to the gateway xlog("L_INFO", "CALL: PSTN $tu from $fu \n"); rewritehostport("ast1.domain.tld:5060"); }; };
#Make sure that all subsequent requests go through us; #done at the top already #record_route(); } else { if (does_uri_exist()) { #Call is to sip client, so do nothing but route xlog("L_INFO", "CALL: Sip client\n"); if (!lookup("location")) { sl_send_reply("404", "Not Found"); xlog("L_ERROR", "ERROR: User $tu Not
Found\n"); return; }; } else { #Call destination is PSTN, so send it to the gateway xlog("L_INFO", "CALL: PSTN $tu from $fu \n"); rewritehostport("ast1.domain.tld:5060"); }; #record_route(); };
#ALL PROCESSING IS DONE, SO ROUTE route(4); route(1);
}
route[1] { #send the call outward if(method=="INVITE" && !isflagset(10)) { t_on_failure("2"); # voicemail if failure };
if (!t_relay()) { xlog("L_WARN", "ERROR: t_relay failed"); sl_reply_error(); };
}
# ----------------------------------------------------------------- # NAT Traversal Section # ----------------------------------------------------------------- route[4] { if (isflagset(6) || isflagset(7)) { if (!isflagset(8)) { setflag(8); use_media_proxy(); }; }; }
failure_route[2] { if(!t_was_cancelled() && !t_check_status("407")) { revert_uri(); rewritehostport("vm.domain.tld:5060"); append_branch(); #PREVENT SOME CRAZY VOICEMAIL LOOP xlog("L_INFO", "INFO: CALL TO VOICEMAIL"); setflag(10); route(1); } }
onreply_route[1] { if ((isflagset(6) || isflagset(7)) && (status=~"(180)|(183)|2[0-9][0-9]")) { if (!search("^Content-Length:[ ]*0")) { use_media_proxy(); }; };
if (client_nat_test("1")) { fix_nated_contact(); };
}