I have configured Kamailio to pass a registration request to another VoIP provider. The reason I am doing this is to provide a sip port for users where the ISP is blocking SIP. I am able to pass the registrations to the VoIP provider but I'd like to have inbound calls working as well. I see the inbound invites coming into the Kamailio server but it appears that the server does not 'know' about the UA that is registered 'through' the server to the VoIP provider. Can anyone tell me how to fix this problem? Below is my config.
Thank you,
Mike
#!KAMAILIO
#
# Edge proxy configuration
#
#!subst "/REGISTRAR_IP/xxxxxxxxxx/" #IP address of voip provider
#!subst "/REGISTRAR_PORT/5060/"
#!substdef "/FLOW_TIMER/20/"
debug=2
log_stderror=no
log_facility=LOG_LOCAL0
fork=yes
children=4
alias="example.com"
#mpath="/usr/lib64/kamailio/modules"
mpath="/usr/lib/x86_64-linux-gnu/kamailio/modules"
tcp_connection_lifetime=30 # FLOW_TIMER + 10
auto_aliases=no
mhomed=0
listen=udp:X.X.X.X:531 advertise X.X.X.X:531
alias="X.X.X.X:531"
alias=X.X.X.X:531
alias="X.X.X.X:531"
alias=X.X.X.X:531
port=531
####### Modules Section ########
loadmodule "tm.so"
loadmodule "sl.so"
#loadmodule "outbound.so"
loadmodule "rr.so"
loadmodule "path.so"
loadmodule "pv.so"
loadmodule "maxfwd.so"
loadmodule "xlog.so"
loadmodule "sanity.so"
loadmodule "ctl.so"
loadmodule "mi_rpc.so"
loadmodule "mi_fifo.so"
loadmodule "textops.so"
loadmodule "siputils.so"
loadmodule "rtimer.so"
loadmodule "sqlops.so"
# ----------------- setting module-specific parameters ---------------
# ----- mi_fifo params -----
modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")
# ----- tm params -----
modparam("tm", "failure_reply_mode", 3)
# ----- rr params -----
modparam("rr", "append_fromtag", 0)
####### Routing Logic ########
request_route {
route(REQINIT);
if (is_method("CANCEL")) {
if (t_check_trans()) {
route(RELAY);
}
exit;
}
route(WITHINDLG);
t_check_trans();
if (is_method("REGISTER")) {
remove_hf("Route");
add_path();
$du = "sip:REGISTRAR_IP:REGISTRAR_PORT";
} else {
if (is_method("INVITE|SUBSCRIBE"))
record_route();
if ($si == "REGISTRAR_IP" && $sp == "REGISTRAR_PORT") {
if (!loose_route()) {
switch($rc) {
case -2:
sl_send_reply("403", "Forbidden");
exit;
default:
sl_reply_error();
exit;
}
}
t_on_failure("FAIL_OUTBOUND");
} else {
if ($rU == $null) {
sl_send_reply("484", "Address Incomplete");
exit;
}
remove_hf("Route");
$du = "sip:REGISTRAR_IP:REGISTRAR_PORT";
}
}
route(RELAY);
}
route[RELAY] {
if (!t_relay()) {
sl_reply_error();
}
exit;
}
route[REQINIT] {
if (!mf_process_maxfwd_header("10")) {
sl_send_reply("483","Too Many Hops");
exit;
}
if(!sanity_check("1511", "7"))
{
xlog("Malformed SIP message from $si:$sp\n");
exit;
}
}
route[WITHINDLG] {
if (has_totag()) {
if (!loose_route()) {
switch($rc) {
case -2:
sl_send_reply("403", "Forbidden");
exit;
default:
if (is_method("ACK")) {
if ( t_check_trans() ) {
route(RELAY);
exit;
} else {
exit;
}
}
sl_send_reply("404","Not Found");
}
} else {
if (is_method("NOTIFY")) {
record_route();
}
route(RELAY);
}
exit;
}
}
onreply_route {
if (!t_check_trans()) {
drop;
}
if ($rm == "REGISTER" && $rs >= 200 && $rs <= 299) {
remove_hf("Flow-Timer");
if ($(hdr(Require)[*])=~"outbound")
insert_hf("Flow-Timer: FLOW_TIMER\r\n", "Call-ID");
}
}
failure_route[FAIL_OUTBOUND]{
if (t_branch_timeout() || !t_branch_replied()) {
send_reply("430", "Flow Failed");
}
}
On Thu, Aug 25, 2016 at 09:38:12AM -0400, Mike Patterson wrote:
I have configured Kamailio to pass a registration request to another VoIP provider. The reason I am doing this is to provide a sip port for users where the ISP is blocking SIP. I am able to pass the registrations to the VoIP provider but I'd like to have inbound calls working as well. I see the inbound invites coming into the Kamailio server but it appears that the server does not 'know' about the UA that is registered 'through' the server to the VoIP provider. Can anyone tell me how to fix this problem? Below is my config.
You should look into the NAT handling tricks: http://www.kamailio.org/docs/modules/stable/modules/nathelper.html#nathelper... and http://kamailio.org/docs/modules/stable/modules/nathelper.html#nathelper.f.h...
Take a look at the default config NATMANAGE routes and enable "natting" for all sources except you upstream server.
Alternatively if the registrar of the voip provider supports Path, enable that in kamailio use http://kamailio.org/docs/modules/stable/modules/path.html#idp38122172 in the registers to add the header and set http://kamailio.org/docs/modules/stable/modules/path.html#idp38033932 to handle the INVITEs
Hi Matt, Check out this post and config: https://blog.voipxswitch.com/2016/08/11/kamailio-and-freeswitch-on-the-same-...
It demonstrates how to handle NAT & forward a REGISTER to FreeSWITCH (on localhost) Thanks, Emmanuel
On Thu, Aug 25, 2016 at 9:57 AM, Daniel Tryba d.tryba@pocos.nl wrote:
On Thu, Aug 25, 2016 at 09:38:12AM -0400, Mike Patterson wrote:
I have configured Kamailio to pass a registration request to another VoIP provider. The reason I am doing this is to provide a sip port for users where the ISP is blocking SIP. I am able to pass the registrations to
the
VoIP provider but I'd like to have inbound calls working as well. I see
the
inbound invites coming into the Kamailio server but it appears that the server does not 'know' about the UA that is registered 'through' the
server
to the VoIP provider. Can anyone tell me how to fix this problem?
Below is
my config.
You should look into the NAT handling tricks: http://www.kamailio.org/docs/modules/stable/modules/ nathelper.html#nathelper.set_contact_alias and http://kamailio.org/docs/modules/stable/modules/ nathelper.html#nathelper.f.handle_ruri_alias
Take a look at the default config NATMANAGE routes and enable "natting" for all sources except you upstream server.
Alternatively if the registrar of the voip provider supports Path, enable that in kamailio use http://kamailio.org/docs/modules/stable/modules/path.html#idp38122172 in the registers to add the header and set http://kamailio.org/docs/modules/stable/modules/path.html#idp38033932 to handle the INVITEs
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Am 25.08.2016 um 16:19 schrieb E. Schmidbauer:
Hi Matt, Check out this post and config: https://blog.voipxswitch.com/2016/08/11/kamailio-and-freeswitch-on-the-same-...
It demonstrates how to handle NAT & forward a REGISTER to FreeSWITCH (on localhost) Thanks, Emmanuel
Just a comment (I found this thread as I currently have the some problem). Both provided solutions do use PATH which of course requires PATH support on the registrar. If the reigstrar does not support PATH then things get complicated.
I see 2 solutions: a) if the registrar does NAT traversal (and thus always send SIP messages to the IP:port it received the REGISTER), does not manipulate the received Contact header and the client does not care about manipulated Contact header it may be possible by just applying "fix_nated_contact()" and route messages from the registrar to the client by using the R-URI in the incoming request.
b) if the Contact header must be preserved (strict clients) or if the registrar does not apply NAT traversal, then it is necessary to do heavy message rewriting and registration in the proxy too: - the URI in the Contact forwarded to the registrar must point to the proxy - this URI must be mapped by the proxy to the clients received/NAT address - depending on the requirements (e.g. multiple registrars, multiple domains) the mapping can be simple or complex
Thus, I think a generic solution for registrars without PATH support involves plenty of message manipulation and lot of time and testing.
regards Klaus
On Fri, Sep 02, 2016 at 07:13:13PM +0200, Klaus Darilion wrote:
I see 2 solutions: a) fix_nated_contact
...
b) if the Contact header must be preserved (strict clients) or if the registrar does not apply NAT traversal, then it is necessary to do heavy message rewriting and registration in the proxy too:
- the URI in the Contact forwarded to the registrar must point to the proxy
- this URI must be mapped by the proxy to the clients received/NAT address
- depending on the requirements (e.g. multiple registrars, multiple domains)
the mapping can be simple or complex
Another solution might be to use the topoh/topos modules. Haven't ever tried it on a machine that forwards REGISTERs having glanced the topos code it should work for any SIP message.
Err sorry Mike (not matt)
On Thu, Aug 25, 2016 at 9:57 AM, Daniel Tryba d.tryba@pocos.nl wrote:
On Thu, Aug 25, 2016 at 09:38:12AM -0400, Mike Patterson wrote:
I have configured Kamailio to pass a registration request to another VoIP provider. The reason I am doing this is to provide a sip port for users where the ISP is blocking SIP. I am able to pass the registrations to
the
VoIP provider but I'd like to have inbound calls working as well. I see
the
inbound invites coming into the Kamailio server but it appears that the server does not 'know' about the UA that is registered 'through' the
server
to the VoIP provider. Can anyone tell me how to fix this problem?
Below is
my config.
You should look into the NAT handling tricks: http://www.kamailio.org/docs/modules/stable/modules/ nathelper.html#nathelper.set_contact_alias and http://kamailio.org/docs/modules/stable/modules/ nathelper.html#nathelper.f.handle_ruri_alias
Take a look at the default config NATMANAGE routes and enable "natting" for all sources except you upstream server.
Alternatively if the registrar of the voip provider supports Path, enable that in kamailio use http://kamailio.org/docs/modules/stable/modules/path.html#idp38122172 in the registers to add the header and set http://kamailio.org/docs/modules/stable/modules/path.html#idp38033932 to handle the INVITEs
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
Thank you. I am reviewing the doc. I am new to Kamailio so it will take some time for me.
From: sr-users [mailto:sr-users-bounces@lists.sip-router.org] On Behalf Of E. Schmidbauer Sent: Thursday, August 25, 2016 10:22 AM To: d.tryba@pocos.nl; Kamailio (SER) - Users Mailing List sr-users@lists.sip-router.org Subject: Re: [SR-Users] Kamailio - passing registration to another sip server
Err sorry Mike (not matt)
On Thu, Aug 25, 2016 at 9:57 AM, Daniel Tryba <d.tryba@pocos.nl mailto:d.tryba@pocos.nl > wrote:
On Thu, Aug 25, 2016 at 09:38:12AM -0400, Mike Patterson wrote:
I have configured Kamailio to pass a registration request to another VoIP provider. The reason I am doing this is to provide a sip port for users where the ISP is blocking SIP. I am able to pass the registrations to the VoIP provider but I'd like to have inbound calls working as well. I see the inbound invites coming into the Kamailio server but it appears that the server does not 'know' about the UA that is registered 'through' the server to the VoIP provider. Can anyone tell me how to fix this problem? Below is my config.
You should look into the NAT handling tricks: http://www.kamailio.org/docs/modules/stable/modules/nathelper.html#nathelper... and http://kamailio.org/docs/modules/stable/modules/nathelper.html#nathelper.f.h...
Take a look at the default config NATMANAGE routes and enable "natting" for all sources except you upstream server.
Alternatively if the registrar of the voip provider supports Path, enable that in kamailio use http://kamailio.org/docs/modules/stable/modules/path.html#idp38122172 in the registers to add the header and set http://kamailio.org/docs/modules/stable/modules/path.html#idp38033932 to handle the INVITEs
_______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org mailto:sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
On Thu, Aug 25, 2016 at 01:34:30PM -0400, Mike Patterson wrote:
Thank you. I am reviewing the doc. I am new to Kamailio so it will take some time for me.
Good luck then :)
Here is my slightly redacted config for a setup similar to yours (which is just a loadbalancer/proxy), which uses both contact rewriting (invites) and Path (registers) and dispatcher to contact the backends. It is based on the default config supplied with kamailio (so look there for REQINIT and WITHINDLG and anything not listed here) and has NATting stuff enabled by default (for SIP, RTP is handled elsewhere). I don't pretend to know that it works perfectly, it just works fine for me.
request_route { route(REQINIT); route(NATDETECT); route(WITHINDLG);
if (is_method("INVITE|SUBSCRIBE")) { record_route(); }
if(!is_in_subnet($si, "x.x.x.x/30")) { add_path_received("fromlb"); ds_select_dst(1, 0); t_on_failure("RTF_DISPATCH"); } else { remove_hf("Route"); loose_route(); }
route(RELAY); }
route[NATDETECT] { if(!is_in_subnet($si, "x.x.x.x/30")) { if (!is_method("REGISTER") && is_first_hop()) { set_contact_alias(); } }
return; }
route[NATMANAGE] { if(!is_in_subnet($si, "x.x.x.x/30")) { if (is_reply() && is_first_hop()) { set_contact_alias(); } }
return; }
Thank you for your response. Can you tell me what value I need to put in is_in_subnet? Is this the local network of the Kamailio server or is it the network of the down-stream sip server?
Do you of anyone who might be willing to work with me on this configuration for a fee or bounty?
-----Original Message----- From: sr-users [mailto:sr-users-bounces@lists.sip-router.org] On Behalf Of Daniel Tryba Sent: Friday, August 26, 2016 4:52 AM To: sr-users@lists.sip-router.org Subject: Re: [SR-Users] Kamailio - passing registration to another sip server
On Thu, Aug 25, 2016 at 01:34:30PM -0400, Mike Patterson wrote:
Thank you. I am reviewing the doc. I am new to Kamailio so it will take some time for me.
Good luck then :)
Here is my slightly redacted config for a setup similar to yours (which is just a loadbalancer/proxy), which uses both contact rewriting (invites) and Path (registers) and dispatcher to contact the backends. It is based on the default config supplied with kamailio (so look there for REQINIT and WITHINDLG and anything not listed here) and has NATting stuff enabled by default (for SIP, RTP is handled elsewhere). I don't pretend to know that it works perfectly, it just works fine for me.
request_route { route(REQINIT); route(NATDETECT); route(WITHINDLG);
if (is_method("INVITE|SUBSCRIBE")) { record_route(); }
if(!is_in_subnet($si, "x.x.x.x/30")) { add_path_received("fromlb"); ds_select_dst(1, 0); t_on_failure("RTF_DISPATCH"); } else { remove_hf("Route"); loose_route(); }
route(RELAY); }
route[NATDETECT] { if(!is_in_subnet($si, "x.x.x.x/30")) { if (!is_method("REGISTER") && is_first_hop()) { set_contact_alias(); } }
return; }
route[NATMANAGE] { if(!is_in_subnet($si, "x.x.x.x/30")) { if (is_reply() && is_first_hop()) { set_contact_alias(); } }
return; }
_______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
On Fri, Aug 26, 2016 at 07:39:02AM -0400, Mike Patterson wrote:
Thank you for your response. Can you tell me what value I need to put in is_in_subnet? Is this the local network of the Kamailio server or is it the network of the down-stream sip server?
It is the subnet (or ip) of your downstream sip server.
Do you of anyone who might be willing to work with me on this configuration for a fee or bounty?
I can only speak for myself: I try to answer questions to help others solve problems that I have figured out myself (many times by digging in the archives here) and to see if there are better solutions available. I'm not willing nor do I have the time to help commercially myself directly. Just ask your questions here and hope someone will reply, the only alternative is to hire a Kamailio consultant: https://www.kamailio.org/w/business-directory/ Or try the commercial mailinglist: business@lists.kamailio.org