Hi all, before hand thanks for all the support
received on this channel.
I have an issue with an installed server on a aws instance which is
giving me routing loops, my setup is simple, i have alias set for both
ips internal and external and the loop still present when t_relay don't
find any routes to relay it just sent it to itself with the public ip
then the loop starts.
can any one please advise how can i prevent that or just tell t_relay
that if there is no more routes just respond with a cancel or stop
searching.
If you call t_relay, then the message will be forwarded to $ru (or to
$du if $du is set). t_relay itself does not have any logic inside.
Thus, if you do not want a message to be forwarded, then you must not
call t_relay.
If you do not want to send a message to a certain destination, then
set $ru (the domain part) to the respective destination.
One issue may be the aliases. If Kamailio thinks that it is not
authoritative for a domain, then it forwards the message to the
domain. Kamailio by default feels authoritative for the IP addresses
on which it listens (the private IP addresses). Thus if a request is
received by Kamailio, but the RURI (request URI, $ru) indicated the
public IP address, KAmailio by default forwards the message to the
respective RURI (which my be forward again by AWS NAT to Kamailio).
Thus, alias=public.ip.addr.ess must be added to the config.
If there are still problems you have set debug=4 and track in the log
file how the message is processed, and where the routing decision
takes the wrong direction.
regards
Klaus
same thing happens when a gw code is not found on the dispatcher list
file.
as i had read by just specifying the alias=domain it should take care of
it but it is not happening perhaps because it is a AWS instance, or most
likely i am missing something after the T_relay to stop the call from
looping.
I do have several headers fix because i have an asterisk sending calls
with lots of signalling calls added to the call that i need to remove
before the call is passed out to a carrier or another UA, Kamailio is
just proxing the calls between asterisk and the outside world no Media
handling, No registrations.
Again thanks for any tips to find my answer or if anyone had a similar
issue thanks again.
thanks for any help .
Julian.
on this setup i have
public ip as 2.2.2.2
private IP as 1.1.1.1
#!KAMAILIO
####### Global Parameters #########
#!ifdef WITH_DEBUG
debug=4
log_stderror=yes
#!else
#debug=2
#log_stderror=yes
#!endif
memdbg=5
memlog=5
log_facility=LOG_LOCAL7
fork=yes
children=6
auto_aliases=no
listen=udp:1.1.1.1:5060 <http://1.1.1.1:5060> advertise 2.2.2.2:5060
<http://2.2.2.2:5060>
alias=1.1.1.1:5060 <http://1.1.1.1:5060>
alias=1.1.1.1
alias=2.2.2.2:5060 <http://2.2.2.2:5060>
alias=2.2.2.2
port=5060
enable_tls=no
#tcp_connection_lifetime=3605
#!ifdef WITH_SRCPATH
mpath="modules_k:modules"
#!else
mpath="/usr/lib64/kamailio/modules_k/:/usr/lib64/kamailio/modules/"
#!endif
loadmodule "db_mysql.so"
##loadmodule "mi_fifo.so"
loadmodule "tm.so"
loadmodule "sl.so"
loadmodule "acc.so"
loadmodule "rr.so"
loadmodule "maxfwd.so"
loadmodule "uac.so"
loadmodule "textops.so"
loadmodule "pv.so"
loadmodule "dispatcher.so"
loadmodule "usrloc.so"
loadmodule "registrar.so"
loadmodule "siputils.so"
loadmodule "sanity.so"
loadmodule "ctl.so"
loadmodule "mi_rpc.so"
loadmodule "avpops.so"
#!ifdef WITH_NAT
loadmodule "nathelper.so"
loadmodule "rtpproxy.so"
#!endif
loadmodule "xlog.so"
##mysqlcdr
modparam("acc", "db_flag", 2)
modparam("acc", "db_missed_flag", 3)
modparam("acc", "report_cancels", 1)
modparam("acc", "db_url",
"mysql://openser:password@1.1.1.2/openser
<http://openser:password@1.1.1.2/openser>")
modparam("acc", "db_extra", "from_uri=$fu; to_uri=$tu;
intid=$fU;
type_call=$si; dst_ip=$ru; carriercode=$tu;callmode=$var(out)" )
#loadmodule "carrierroute"
modparam("tm", "cancel_b_method", 1)
modparam("tm", "failure_reply_mode", 3)
modparam("tm", "fr_timer", 30000)
modparam("tm", "fr_inv_timer", 120000)
modparam("dispatcher", "list_file",
"/etc/kamailio/dispatcher.lst")
modparam("rr", "enable_full_lr", 1)
#!ifdef WITH_NAT
# ----- rtpproxy params -----
modparam("rtpproxy", "rtpproxy_sock", "udp:127.0.0.1:7722
<http://127.0.0.1:7722>")
# ----- nathelper params -----
modparam("nathelper", "natping_interval", 30)
modparam("nathelper", "ping_nated_only", 1)
modparam("nathelper", "sipping_bflag", FLB_NATSIPPING)
modparam("nathelper", "sipping_from", "sip:pinger@kamailio.org
<mailto:sip%3Apinger@kamailio.org>")
# ----- mi_fifo params -----
##modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")
# params needed for NAT traversal in other modules
modparam("nathelper|registrar", "received_avp",
"$avp(RECEIVED)")
modparam("usrloc", "nat_bflag", FLB_NATB)
#!endif
modparam("xlog", "buf_size", 8192)
modparam("xlog", "force_color", 1)
#carrierroute
#modparam("carrierroute", "config_file",
"/etc/kamailio/carrierroute.conf")
#end carrierroute
modparam("pv", "shvset", "ruta=s:$ru")
modparam("pv", "varset","in=s:IN")
modparam("pv", "varset","out=s:OUT")
#################BEGINING MAINROUTE##################
request_route {
if (!mf_process_maxfwd_header("4")) {
sl_send_reply("483","Too Many Hops");
drop;
exit;
}
##
# initial sanity checks -- too long messages
if (msg:len >= 2048 ) {
sl_send_reply("513", "Message too big");
xlog("out header CHECK 513 baderror from_uri=$fu;($ct++)<$tU---=$var(n)>
to_uri=$tu; intid=$fU; type_call=$si; dst_ip=$ru;
carriercode=$var(z);callmode=$var(out)");
drop;
exit;
};
#
if(is_method("OPTIONS")) {
# send reply for each options request
sl_send_reply("200", "ok");
exit();
}
#
if ( is_method("ACK") ) {
if ( t_check_trans() ) {
# no loose-route, but stateful ACK;
# must be an ACK after a 487
# or e.g. 404 from upstream server
$var(n)=$(tU{s.substr,3,0});
$var(i)=$(ct{re.subst,/^.*11811(.*)/"\1/});
$var(t)=$(fn{re.subst,/^.*11811(.*)/"\1/});
$var(r)=$rd; ##to domain
$fU=$(fU{s.substr,14,0});
$fn=$var(t);
$tU=$var(n);
$td=$var(r);
subst('/^Contact:.*11811(.*)$/Contact: <sip:\1\2/ig');
# Remove prefixes numbers from Contact\
t_relay();
exit;
} else {
# ACK without matching transaction ... ignore and discard
$var(n)=$(tU{s.substr,3,0});
$var(i)=$(ct{re.subst,/^.*11811(.*)/"\1/});
$var(t)=$(fn{re.subst,/^.*11811(.*)/"\1/});
$var(r)=$rd; ##to domain
$fU=$(fU{s.substr,14,0});
$fn=$var(t);
$tU=$var(n);
$td=$var(r);
subst('/^Contact:.*11811(.*)$/Contact: <sip:\1\2/ig');
t_relay();
exit;
}
}
##responding to bye requests and modifying headers to match invite
if(method=="BYE") {
#Account BYE transactions
#$var(d) = $tu;
#$var(e)=$(var(d){s.substr,4,3});
setflag(2);
setflag(10);
$var(n)=$(tU{s.substr,3,0});
$var(i)=$(ct{re.subst,/^.*11811(.*)/"\1/});
$var(t)=$(fn{re.subst,/^.*11811(.*)/"\1/});
$var(r)=$rd; ##to domain
$fU=$(fU{s.substr,14,0});
$fn=$var(t);
$tU=$var(n);
$td=$var(r);
subst('/^Contact:.*11811(.*)$/Contact: <sip:\1\2/ig');
t_relay();
exit;
};
#CANCEL processing
if (method=="CANCEL") {
setflag(2);
setflag(3);
$var(n)=$(tU{s.substr,3,0});
$var(i)=$(ct{re.subst,/^.*11811(.*)/"\1/});
$var(t)=$(fn{re.subst,/^.*11811(.*)/"\1/});
$var(r)=$rd; ##to domain
$fU=$(fU{s.substr,14,0});
$fn=$var(t);
$tU=$var(n);
$td=$var(r);
subst('/^Contact:.*11811(.*)$/Contact: <sip:\1\2/ig');
t_relay();
exit;
##if (t_check_trans()) t_relay();
exit;
};
#
#
if (loose_route()) {
##
if(is_method("OPTIONS")) {
# send reply for each options request
sl_send_reply("200", "ok");
exit();
}
##
if(method=="BYE") {
#Account BYE transactions
setflag(2);
};
##CANCEL processing
if (method=="CANCEL") {
setflag(3);
$var(n)=$(tU{s.substr,3,0});
$var(i)=$(ct{re.subst,/^.*11811(.*)/"\1/});
$var(t)=$(fn{re.subst,/^.*11811(.*)/"\1/});
$var(r)=$rd; ##to domain
$fU=$(fU{s.substr,14,0});
$fn=$var(t);
$tU=$var(n);
$td=$var(r);
subst('/^Contact:.*11811(.*)$/Contact: <sip:\1\2/ig');
if (t_check_trans()) t_relay();
exit;
};
if (!t_relay()) {
sl_reply_error();
}
exit;
}
if (is_method("INVITE")) { #Procesing invites
record_route();
}
##LOGGING CALL BEFORE IS PROCESSED
xlog("before strip,< time [$Tf] > Aip= $src_ip, r-uri($ru\n");
xlog("before from_uri=$fu; to_uri=$tu; pai=<<$ct>>;intid=$fU;
type_call=$si; dst_ip=$ru; carriercode=$tu;callmode=$var(out)
--$$--$ou");
#creando rutas
setflag(2);
# Account Missed calls
setflag(3);
###VARIABLES FOR MODIFICATIONS
$var(x) = $(ru);
$var(y)=$(var(x){s.substr,4,3});
$var(z)=$(var(y){s.int <http://s.int>});
$var(t)=$(var(x){s.substr,7,0});
$var(h)=$(var(x){s.substr,0,7});
$var(o)=$(fU{s.substr,14,0});
if($(var(x){s.len}) < 3)
{
$var(z)='0'+ $var(z);
}
xlog("dsroute $var(z)fullruri($ru)\n");
strip(3);
xlog("after strip time [$Tf] method ($rm) via el code
($var(z)--varhex($var(h))-- ($var(y))\n");
xlog("after from_uri=$fu; to_uri=$tu; intid=$fU; type_call=$si;
dst_ip=$ru; carriercode=$var(z);callmode=$var(out)");
ds_select_domain ("$var(z)", "4");#carrer dynamic
###########KILLING BUGGIES#######when t_realy fails to find a route a
loop is generate then strip takes off a digit until 0(a)2.2.2.2
<mailto:0@2.2.2.2> is left for to: user this kills that call.#####
if ($(tU{s.len}) < 4) {
xlog("CHECK TU 1bad kILLING BUGGIES>>> $tu--$td-$tU-$tt--$dd-$dd-$du-
-<<$rd>$ru --- $oU> pai+++ <<$ct>>++
from_uri=$fu;<$tU---=$var(n)>
to_uri=$tu; }pai<$ai> id=$fU; type_call=$si; dst_ip=$ru;
carriercode=$var(z);callmode=$var(out)");
##sl_reply_error();
##sl_send_reply("513", "Message too big");
##sl_send_reply("488","Not Acceptable Here");
sl_send_reply("488","Not Acceptable Here");
#t_reset_retr();
#t_release();
##if(!t_relay()){ sl_reply_error(); drop; exit;}
#if (!t_relay()) { sl_reply_error(); break; };
# t_relay();
#setflag(2);
drop;
exit;
}; ## Endif less than 4
##############END KILLING###########
################ROUTE SELECTION###############
if($(fn{s.len}) > 10) { # IF WE CHECK FOR FROM: ROUTEID MUST BE LONGER
THAN 10 DIGITS TO BE A VALID ROUTE
xlog("out header CHECK more than 10 digits BEFORE
from_uri=$fu;($ct++)<$tU---=$var(n)> to_uri=$tu; intid=$fU;
type_call=$si; dst_ip=$ru; carriercode=$var(z);callmode=$var(out)");
$var(n)=$(tU{s.substr,3,0});
$var(i)=$(ct{re.subst,/^.*00700(.*)/"\1/});
$var(t)=$(fn{re.subst,/^.*00700(.*)/"\1/});
$var(r)=$rd; ##to domain
$fU=$(fU{s.substr,14,0});
$fn=$var(t);
$tU=$var(n);
$td=$var(r);
subst('/^Contact:.*11811(.*)$/Contact: <sip:\1\2/ig'); # Remove number
from Contact
##if(!t_relay()){ sl_reply_error(); drop; exit;}
if (!t_relay()) { sl_reply_error(); break; };
# t_relay();
drop;
exit;
};
################ENDrouteselect##############################
###############AFTER LAST IF##############reply 488 ANY CALL THAT DID
NOT FOUND A ROUTE.
sl_send_reply("488","Not Acceptable Here");
drop;
exit;
}
###################END MAINROUTE#################
On My dispatcher.lst i have
1 sip:1.1.1.1:5060 <http://1.1.1.1:5060>
2 sip:2.2.2.2:5060 <http://2.2.2.2:5060>
3 sip:3.3.3.3:5060 <http://3.3.3.3:5060>
3 sip:3.3.3.5:5060 <http://3.3.3.5:5060>
...
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users(a)lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users(a)lists.sip-router.org