Thank you for your answer Pablo,
Pablo Hernan Saro ha scritto:
Considering what you explained, I don't see any
other solution than
letting asterisk reach the public net.
Pablo
Well, I think a possible solution could be to force RTP proxy every time
the communication goes to asterisk.
I've also tried to implement it. So even if I have only one NIC I'v
tried to run rtpproxy in bridge mode, distinguishing users registered
from the outside network from those registerd from the inside network.
Starting from the alg.cfg script found in the openser example this is
what I do:
-use two differente location tables
- always force rtpproxy distinguisching from itnternal/ external registered
But I've some problems with 200OK answers, the client registered from
the outside don't send the ACK.
I've tried to add a 'set_adevertised address' with th epubli IP but with
no luck.
Please have a look at the .cfg attached.
Thanks in advance,
Cosimo Fadda
On Tue, Nov 25, 2008 at 12:14 PM, Cosimo Fadda
<cfadda.lists(a)gmail.com
<mailto:cfadda.lists@gmail.com>> wrote:
Hi everybody,
so, I'm tryng to use Openser and Asterisk toghether in this scenario:
Ser and Asterisk are in the same LAN 10.2.7.X, and they are both
behind
a firewall.
SER can be reached from the outside network via a Public IP
forwarded to it,
Asterisck can only be reached from Ser, and it cannot reach the ouside
network.
I'm using Ser as proxy and registrar, all requests are forwarded to
Asteisk by the proxy.
In this way I can use all the feature of Asterisk.
Users can regiser to Ser both via the private LAN and the public
IP , so
I have to distinguish from where calls are coming from
in order to properly initialize rtpproxy.
IF a client is registered from the outsie and it has a Public IP,
rtpproxy is not called and the Asterisk try to send the media directly
to it,
but since asterisk cannot reach the outside network, no media is
passed.
How can I fix this?
Thanks in advance for any hints,
Cosimo
_______________________________________________
Users mailing list
Users(a)lists.kamailio.org <mailto:Users@lists.kamailio.org>
http://lists.kamailio.org/cgi-bin/mailman/listinfo/users
########################################################################
# This configuration was updated on Tue Nov 25 10:34:20 CET 2008
# From Version: alg.cfg, openser2411.cfg
# Author: Cosimo Fadda
########################################################################
########################################################################
# Configuration:
# - Local DB
# - rtpproxy active in bridge mode
# - from/to asterisk handling
# - two different Location Tables
#
########################################################################
########################################################################
# Notice:
# - need adjustments (wrong ACK handling)
# -
########################################################################
########################################################################
# General Configuration
########################################################################
listen=udp:10.2.7.2:5060
server_header="Server: OpenVoice SIP Proxy"
children=3
debug=3 # debug level (cmd line: -dddddddddd)
fork=yes
log_stderror=no # (cmd line: -E)
log_facility=LOG_LOCAL7
port=5060
check_via=no # (cmd. line: -v)
dns=no # (cmd. line: -r)
rev_dns=no # (cmd. line: -R)
########################################################################
#
# Modules Configuration
#
########################################################################
mpath = "/usr/local/lib/openser/modules"
loadmodule "usrloc.so"
modparam("usrloc", "user_column", "username")
modparam("usrloc", "domain_column", "domain")
modparam("usrloc", "contact_column", "contact")
modparam("usrloc", "expires_column", "expires")
modparam("usrloc", "q_column", "q")
modparam("usrloc", "callid_column", "callid")
modparam("usrloc", "cseq_column", "cseq")
modparam("usrloc", "methods_column", "methods")
modparam("usrloc", "flags_column", "flags")
modparam("usrloc", "user_agent_column", "user_agent")
modparam("usrloc", "received_column", "received")
modparam("usrloc", "socket_column", "socket")
modparam("usrloc", "use_domain", 0)
modparam("usrloc", "desc_time_order", 0)
modparam("usrloc", "timer_interval", 60)
modparam("usrloc", "db_url",
"mysql://openser:openserrw@localhost/openser")
modparam("usrloc", "db_mode", 1)
modparam("usrloc", "matching_mode", 0)
modparam("usrloc", "cseq_delay", 20)
modparam("usrloc", "nat_bflag", 6)
loadmodule "textops.so"
loadmodule "rr.so"
modparam("rr", "enable_full_lr", 1)
modparam("rr", "append_fromtag", 1)
modparam("rr", "enable_double_rr", 1)
modparam("rr", "add_username", 0)
loadmodule "tm.so"
modparam("tm", "fr_timer", 7)
modparam("tm", "fr_inv_timer", 75)
modparam("tm", "wt_timer", 5)
modparam("tm", "delete_timer", 2)
modparam("tm", "noisy_ctimer", 1)
modparam("tm", "ruri_matching", 1)
modparam("tm", "via1_matching", 1)
modparam("tm", "unix_tx_timeout", 2)
modparam("tm", "restart_fr_on_each_reply", 1)
modparam("tm", "pass_provisional_replies", 0)
loadmodule "xlog.so"
modparam("xlog", "buf_size", 4096)
modparam("xlog", "force_color", 0)
loadmodule "mi_fifo.so"
modparam("mi_fifo", "fifo_name", "/tmp/openser_fifo")
loadmodule "domain.so"
modparam("domain", "db_url",
"mysql://openser:openserrw@localhost/openser")
modparam("domain", "db_mode", 1)
modparam("domain", "domain_table", "domain")
modparam("domain", "domain_col", "domain")
loadmodule "nathelper.so"
modparam("nathelper", "natping_interval", 30)
modparam("nathelper", "ping_nated_only", 1)
modparam("nathelper", "rtpproxy_sock",
"unix:/var/run/rtpproxy.sock")
#modparam("nathelper", "rtpproxy_disable", 0)
modparam("nathelper", "rtpproxy_disable_tout", 60)
modparam("nathelper", "rtpproxy_tout", 1)
modparam("nathelper", "rtpproxy_retr", 5)
modparam("nathelper", "sipping_method", "OPTIONS")
modparam("nathelper", "received_avp", "$avp(i:801)")
loadmodule "sl.so"
modparam("sl", "enable_stats", 1)
loadmodule "uri.so"
loadmodule "registrar.so"
modparam("registrar", "default_expires", 1800)
modparam("registrar", "min_expires", 60)
modparam("registrar", "max_expires", 0)
modparam("registrar", "default_q", 0)
modparam("registrar", "append_branches", 1)
modparam("registrar", "case_sensitive", 0)
modparam("registrar", "received_param", "received")
modparam("registrar", "max_contacts", 0)
modparam("registrar", "retry_after", 0)
modparam("registrar", "method_filtering", 0)
modparam("registrar", "path_mode", 2)
modparam("registrar", "path_use_received", 0)
modparam("registrar", "received_avp", "$avp(i:801)")
loadmodule "maxfwd.so"
modparam("maxfwd", "max_limit", 256)
loadmodule "mysql.so"
modparam("mysql", "ping_interval", 300)
modparam("mysql", "auto_reconnect", 1)
loadmodule "auth.so"
modparam("auth", "nonce_expire", 300)
modparam("auth", "rpid_suffix",
";party=calling;id-type=subscriber;screen=yes")
modparam("auth", "rpid_avp", "$avp(s:rpid)")
loadmodule "auth_db.so"
modparam("auth_db", "db_url",
"mysql://openser:openserrw@localhost/openser")
modparam("auth_db", "user_column", "username")
modparam("auth_db", "domain_column", "domain")
#modparam("auth_db", "password_column", "ha1")
modparam("auth_db", "password_column", "password")
#modparam("auth_db", "password_column_2", "ha1b")
modparam("auth_db", "calculate_ha1", 1)
#modparam("auth_db", "calculate_ha1", 0)
modparam("auth_db", "use_domain", 0)
modparam("auth_db", "load_credentials", "rpid")
loadmodule "uri_db.so"
modparam("uri_db", "db_url",
"mysql://openser:openserrw@localhost/openser")
modparam("uri_db", "uri_table", "uri")
modparam("uri_db", "uri_user_column", "username")
modparam("uri_db", "uri_domain_column", "domain")
modparam("uri_db", "uri_uriuser_column", "uri_user")
modparam("uri_db", "subscriber_table", "subscriber")
modparam("uri_db", "subscriber_user_column", "username")
modparam("uri_db", "subscriber_domain_column", "domain")
modparam("uri_db", "use_uri_table", 0)
modparam("uri_db", "use_domain", 0)
loadmodule "avpops.so"
modparam("avpops", "db_url",
"mysql://openser:openserrw@localhost/openser")
modparam("avpops", "avp_table", "usr_preferences")
modparam("avpops", "use_domain", 0)
modparam("avpops", "uuid_column", "username")
modparam("avpops", "username_column", "username")
modparam("avpops", "domain_column", "domain")
modparam("avpops", "attribute_column", "attribute")
modparam("avpops", "value_column", "value")
modparam("avpops", "type_column", "type")
loadmodule "dispatcher.so"
modparam("dispatcher", "db_url",
"mysql://openser:openserrw@localhost/openser")
modparam("dispatcher", "table_name", "dispatcher")
modparam("dispatcher", "setid_col", "setid")
modparam("dispatcher", "destination_col", "destination")
modparam("dispatcher", "flags", 2) # fail-over mode
modparam("dispatcher", "dst_avp", "$avp(i:271)")
modparam("dispatcher", "grp_avp", "$avp(i:272)")
modparam("dispatcher", "cnt_avp", "$avp(i:273)")
#modparam("dispatcher", "force_dst", 1)
########################################################################
#
#Routing Definitions
#
########################################################################
########################################################################
# Request route 'main'
########################################################################
route[0]
{
# -----------------------------------------------------------------
# Sanity Check Section
# -----------------------------------------------------------------
if (!mf_process_maxfwd_header("10"))
{
sl_send_reply("483", "Too Many Hops");
exit;
};
if (msg:len > max_len)
{
sl_send_reply("513", "Message Overflow");
exit;
};
if (method == "REGISTER")
{
route(2);
exit;
};
# -----------------------------------------------------------------
# RTP Proxy Teardown Section
# -----------------------------------------------------------------
if (method == "BYE" || method == "CANCEL")
{
unforce_rtp_proxy();
};
# -----------------------------------------------------------------
# Loose Route Section
# -----------------------------------------------------------------
if (method != "REGISTER")
{
record_route();
};
if (loose_route())
{
route(1);
exit;
};
# -----------------------------------------------------------------
# Call Type Processing Section
# -----------------------------------------------------------------
if(is_method("CANCEL"))
#if(is_method("CANCEL") || is_method("ACK"))
{
route(1);
}
else if (method == "INVITE")
{
route(3);
exit;
}
else if ((method=="OPTIONS") || (method=="SUBSCRIBE") ||
(method=="NOTIFY") || (method=="PUBLISH") || (method ==
"MESSAGE"))
{
route(12);
exit;
}
if ($rU==NULL)
{
# request with no Username in RURI
route(16);
}
if (!lookup("location_internal"))
{
if (!lookup("location_external"))
{
if (method != "ACK")
sl_send_reply("403", "Call cannot be served here");
exit;
};
};
route(1);
}
########################################################################
# Default Message Handler
########################################################################
route[1]
{
if (!t_relay())
sl_reply_error();
}
########################################################################
# REGISTER Message Handler
########################################################################
route[2]
{
if (!search("^Contact:[ ]*\*") && nat_uac_test("19"))
{
setflag(6);
fix_nated_register();
force_rport();
};
sl_send_reply("100", "Trying");
if(!www_authorize("sip.wonderland.it", "subscriber"))
{
xlog("L_INFO", "Register authentication failed - M=$rm RURI=$ru F=$fu
T=$tu IP=$si ID=$ci\n");
www_challenge("sip.wonderland.it", "0");
exit;
}
if(!check_to())
{
xlog("L_INFO", "Spoofed To-URI detected - M=$rm RURI=$ru F=$fu T=$tu
IP=$si ID=$ci\n");
sl_send_reply("403", "Spoofed To-URI Detected");
exit;
}
consume_credentials();
# -----------------------------------------------------------------
# Save user location based on which URI the REGISTER
# was sent to.
# -----------------------------------------------------------------
if (to_uri=~"sip:.+@10.2.7.2")
{
xlog("L_INFO", "REG for Internal IP address - M=$rm RURI=$ru F=$fu T=$tu
IP=$si ID=$ci\n");
if (!save("location_internal"))
{
sl_reply_error();
};
}
else if (to_uri=~"sip:.+@90.80.70.60")
{
xlog("L_INFO", "REG forExternal IP address - M=$rm RURI=$ru F=$fu T=$tu
IP=$si ID=$ci\n");
if (!save("location_external"))
{
sl_reply_error();
};
}
else
{
sl_send_reply("403", "Call cannot be served here");
};
}
#########################################################################
# INVITE Message Handler
#########################################################################
route[3]
{
# -----------------------------------------------------------------
# Set flags based on which interface the INVITE was sent to.
# -----------------------------------------------------------------
if (to_uri=~"sip:.+@10.2.7.2")
{
xlog("L_INFO", "Invite from Internal IP address - M=$rm
RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");
setflag(11);
}
else if (to_uri=~"sip:.+@90.80.70.60")
{
xlog("L_INFO", "Invite from External IP address - M=$rm RURI=$ru F=$fu
T=$tu IP=$si ID=$ci\n");
setflag(12);
};
# -----------------------------------------------------------------
# Perform custom INVITE rewriting that depends upon user
# credentials here. Don't forget to drop any credentials
# you've collected if control flow doesn't reach the next line.
# -----------------------------------------------------------------
consume_credentials();
route(6);
}
#########################################################################
# Common Routing
#########################################################################
route[6]
{
# -----------------------------------------------------------------
# We first ditinguish if the call is coming from Asterisk.
# Then, since we set flags 11 and 12 for SIP messages arriving
# on the private and public interfaces, respectively (see route[3]),
# we compare the location of the called party (via lookup()) to the location
# of the calling party (flags 11/12) to determine which interface of the RTP proxy
# we need to set up .
# We always setup RTPProxy regardless NAT
# -----------------------------------------------------------------
if(src_ip==10.2.7.3)
{
xlog("L_INFO", "Invite from Asterisk - M=$rm RURI=$ru F=$fu T=$tu
IP=$si ID=$ci\n");
if (lookup("location_internal"))
{
if (isflagset(11))
{
if (force_rtp_proxy("FAII"))
t_on_reply("1");
}
else if (isflagset(12))
{
if (force_rtp_proxy("FAEI"))
t_on_reply("1");
};
}
else if (lookup("location_external"))
{
if (isflagset(11))
{
if (force_rtp_proxy("FAIE"))
t_on_reply("1");
}
else if (isflagset(12))
{
if (force_rtp_proxy("FAEE"))
t_on_reply("1");
};
}
else
{
sl_send_reply("480", "Temporarily Unavailable");
exit;
};
route(1);
}
else if (uri =~ "^sip:[0-9]+@")
{
if (isflagset(11))
{
if (force_rtp_proxy("FAEI"))
xlog("L_INFO", "RTP Internal IP address - M=$rm
RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");
t_on_reply("1");
}
else if (isflagset(12))
{
if (force_rtp_proxy("FAEE"))
xlog("L_INFO", "RTP External IP address - M=$rm
RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");
t_on_reply("1");
}
rewritehost("10.2.7.3");
route(1);
exit;
}
else
{
sl_send_reply("403", "Destination NOT Allowed");
exit;
};
}
########################################################################
# Request route 'base-route-local'
########################################################################
route[11]
{
t_on_reply("1");
if(t_check_trans())
{
xlog("L_INFO", "Request leaving server - M=$rm RURI=$ru F=$fu T=$tu
IP=$si ID=$ci\n");
if(!t_relay())
{
sl_reply_error();
}
}
else
{
xlog("L_INFO", "Dropping mis-routed request - M=$rm RURI=$ru F=$fu T=$tu
IP=$si ID=$ci\n");
}
exit;
}
########################################################################
# Request route 'base-route-generic'
########################################################################
route[12]
{
xlog("L_INFO", "Method not supported - M=$rm RURI=$ru F=$fu T=$tu IP=$si
ID=$ci\n");
sl_send_reply("501", "Method Not Supported Here");
exit;
}
########################################################################
# Request route 'base-incomplete-failover'
########################################################################
route[16]
{
xlog("L_INFO", "Address Incomplete - M=$rm RURI=$ru F=$fu T=$tu IP=$si
ID=$ci\n");
sl_send_reply("484","Address Incomplete");
exit;
}
########################################################################
# Reply route 'base-standard-reply'
########################################################################
onreply_route[1]
{
if (!(status =~ "183" || status =~ "200"))
exit;
xlog("L_INFO", "Forcing RTP on reply - M=$rm RURI=$ru F=$fu T=$tu
IP=$si ID=$ci\n");
force_rtp_proxy("FA");
}