Having trouble Setup Kamailio as a load balancer for Asterisk Server using module Dispatcher

Hello Everyone.

I am having trouble to setting up kamailio for load balancing for asterisk servers.

I am using module dispatcher for load balancing AND two different servers for kamailio and asterisk.

I am doing it first time and have not exact idea about its all configs… but i have researched and done so far, now need help from you guys. Currently, trying to setup with the one kamailio and one asterisk then will go ahead if I get any success…
using mariadb mysql for the dispatcher data.

Simply I want to do is :

  1. Register my asterisk devices with kamailioIP (and I am able to do this using below configs)
    Devices are getting register with the asterisk from with kamailioIP

  2. I want to receive calls on the registered devices with KamailioIP (and i am not able to do this)

WORK FLOW:

KAMAILIO IP = XX.XX.XX.95 on port 5060 and Asterisk IP = XX.XX.XX.164 on port 5060

SIP Device(ZOIPER) -------->>>>KAMAILIO SERVER(device register/load balancer)--------->>> ASTERISK SERVER

Please have a look into my configuration files and let me know if anything is missing or wrong in these. Or anything to add or remove from the confs…

PLEASE HELP to do this, I have search a lot and tried so much of stuff in configs but no success still kindly guide me if anything I am missing to do in the process or anything I am doing wrong.
I will be eagerly waiting for any help or pointer…

Thanks in advance

“kamctl dispatcher dump”
looks like this:

{
“jsonrpc”: “2.0”,
“result”: {
“NRSETS”: 1,
“RECORDS”: [{
“SET”: {
“ID”: 1,
“TARGETS”: [{
“DEST”: {
“URI”: “sip:ASTERISKIP:5060”,
“FLAGS”: “AP”,
“PRIORITY”: 1,
“ATTRS”: {
“BODY”: “rweight=50;weight=50;cc=1”,
“DUID”: “”,
“MAXLOAD”: 0,
“WEIGHT”: 50,
“RWEIGHT”: 50,
“SOCKET”: “”,
“SOCKNAME”: “”,
“OBPROXY”: “”
}
}
}]
}
}]
},
“id”: 13403
}

my kamailio.cfg

“”------------------------------------------------------------------------------------------------------
#!KAMAILIO

#!define WITH_MYSQL
#!define WITH_AUTH
#!define WITH_ASTERISK
#define WITH_NAT
#!define WITH_DEBUG
#!define WITH_USRLOCDB

####### Defined Values #########

####### Global Parameters #########

#!ifdef WITH_DEBUG
debug=4
log_stderror=yes
#!else
debug=2
log_stderror=no
#!endif

memdbg=5
memlog=5

log_facility=LOG_LOCAL7

log_name=“kamailio”

children=4

/* uncomment the next line to disable TCP (default on) */
#disable_tcp=yes

/* uncomment the next line to disable the auto discovery of local aliases
based on reverse DNS on IPs (default on) */
#auto_aliases=no

/* add local domain aliases */
#alias=“sip.mydomain.com

/* uncomment and configure the following line if you want Kamailio to
bind on a specific interface/port/proto (default bind on all available) */
#listen=udp:0.0.0.0:5060
#listen=udp: KamailioIP:5060

/* port to listen to

    • can be specified more than once if needed to listen on many ports */
      port=5060

#!ifdef WITH_TLS
enable_tls=yes
#!endif

#life time of TCP connection when there is no traffic
#a bit higher than registration expires to cope with UA behind NAT
tcp_connection_lifetime=3605

####### Custom Parameters #########

#These parameters can be modified runtime via RPC interface
#-see the documentation of ‘cfg_rpc’ module.

#Format: group.id = value ‘desc’ description
#Access: $sel(cfg_get.group.id) or @cfg_get.group.id

#!ifdef WITH_PSTN
#PSTN GW Routing

#-pstn.gw_ip: valid IP or hostname as string value, example:
#pstn.gw_ip = “10.0.0.101” desc “My PSTN GW Address”

#-by default is empty to avoid misrouting
pstn.gw_ip = “” desc “PSTN GW Address”
#!endif

#!ifdef WITH_VOICEMAIL
#VoiceMail Routing on offline, busy or no answer

#-by default Voicemail server IP is empty to avoid misrouting
voicemail.srv_ip = “” desc “VoiceMail IP Address”
voicemail.srv_port = “5060” desc “VoiceMail Port”
#!endif

#!ifdef WITH_ASTERISK
asterisk.bindip = " ASTERISKIP.164" desc “Asterisk IP Address”
asterisk.bindport = “5060” desc “Asterisk Port”
kamailio.bindip = " KamailioIP .95" desc “Kamailio IP Address”
kamailio.bindport = “5060” desc “Kamailio Port”
#!endif

####### Modules Section ########

#set paths to location of modules (to sources or installation folders)
#!ifdef WITH_SRCPATH
mpath="/usr/local/kamailio-devel/lib64/kamailio/modules/"
#!else
mpath="/usr/local/kamailio-devel/lib64/kamailio/modules/"
#!endif

#!ifdef WITH_MYSQL
loadmodule “db_mysql.so”
#!endif

loadmodule “kex.so”
loadmodule “tm.so”
loadmodule “tmx.so”
loadmodule “sl.so”
loadmodule “rr.so”
loadmodule “pv.so”
loadmodule “maxfwd.so”
loadmodule “usrloc.so”
loadmodule “registrar.so”
loadmodule “textops.so”
loadmodule “siputils.so”
loadmodule “xlog.so”
loadmodule “sanity.so”
loadmodule “ctl.so”
loadmodule “cfg_rpc.so”
loadmodule “acc.so”
loadmodule “sctp.so”
loadmodule “dialog.so”
loadmodule “siptrace.so”

#!ifdef WITH_AUTH
loadmodule “auth.so”
loadmodule “auth_db.so”
#!ifdef WITH_IPAUTH
loadmodule “permissions.so”
#!endif
#!endif

#!ifdef WITH_ALIASDB
loadmodule “alias_db.so”
#!endif

#!ifdef WITH_SPEEDDIAL
loadmodule “speeddial.so”
#!endif

#!ifdef WITH_MULTIDOMAIN
loadmodule “domain.so”
#!endif

#!ifdef WITH_PRESENCE
loadmodule “presence.so”
loadmodule “presence_xml.so”
#!endif

#!ifdef WITH_NAT
loadmodule “nathelper.so”
loadmodule “rtpproxy.so”
#!endif

#!ifdef WITH_TLS
loadmodule “tls.so”
#!endif

#!ifdef WITH_ANTIFLOOD
loadmodule “htable.so”
loadmodule “pike.so”
#!endif

#!ifdef WITH_XMLRPC
loadmodule “xmlrpc.so”
#!endif

#!ifdef WITH_DEBUG
loadmodule “debugger.so”
#!endif

#!ifdef WITH_ASTERISK

loadmodule “uac.so”
loadmodule “dispatcher.so”
loadmodule “jsonrpcs.so”
loadmodule “htable.so”

---------------------- mod dispatcher params ------------------------------

modparam(“dispatcher”, “db_url”, DBURL)
modparam(“dispatcher”, “table_name”, “dispatcher”)
modparam(“dispatcher”, “ds_ping_interval”, 15)
modparam(“dispatcher”, “ds_ping_from”, "sip:dispathcer@ KamailioIP ")
modparam(“dispatcher”, “force_dst”, 1)
modparam(“dispatcher”, “ds_ping_method”, “INFO”)
#modparam(“dispatcher”, “ds_probing_mode”, 1)
modparam(“dispatcher”, “ds_probing_threshold”, 1)
#modparam(“dispatcher”, “ds_ping_reply_codes”, “class=2;code=403;code=404;code=484;code=488;code=481;class=3”)
modparam(“dispatcher”, “ds_ping_reply_codes”, “class=2;class=3;class=4”)
#modparam(“dispatcher”, “priority_col”, “dstpriority”)
#modparam(“dispatcher”, “dstid_avp”, “$avp(dsdstid)”)
#do failover
modparam(“dispatcher”, “flags”, 2)
#modparam(“dispatcher”, “dst_avp”, “$avp(AVP_DST)”)
#modparam(“dispatcher”, “grp_avp”, “$avp(AVP_GRP)”)
#modparam(“dispatcher”, “cnt_avp”, “$avp(AVP_CNT)”)

#!endif

#---------------- setting module-specific parameters ---------------
modparam(“siptrace”, “db_url”, DBURL)
modparam(“siptrace”, “trace_flag”, 22)
modparam(“siptrace”, “trace_on”, 1)
#----- jsonrpcs params -----
modparam(“jsonrpcs”, “pretty_format”, 1)
/* set the path to RPC fifo control file /
#modparam(“jsonrpcs”, “fifo_name”, “/run/kamailio/kamailio_rpc.fifo”)
/
set the path to RPC unix socket control file */
#modparam(“jsonrpcs”, “dgram_socket”, “/run/kamailio/kamailio_rpc.sock”)
#!ifdef WITH_JSONRPC
modparam(“jsonrpcs”, “transport”, 7)
#!endif

#---------------------- mod uac params ------------------------------

modparam(“uac”, “reg_contact_addr”, “ASTERISKIP:5060”)
modparam(“uac”, “reg_db_url”, “mysql://kamailio:kamailiorw@localhost/kamailio”)
modparam(“uac”, “reg_db_table”, “uacreg”)
modparam(“uac”, “reg_timer_interval”, 60)
modparam(“uac”,“restore_mode”,“auto”)
modparam(“uac”, “restore_dlg”, 1)
modparam(“uac”,“auth_realm_avp”,"$avp(s:auth_realm_avp)")
modparam(“uac”,“auth_username_avp”,"$avp(s:auth_username_avp)")
modparam(“uac”,“auth_password_avp”,"$avp(s:auth_password_avp)")

#----- mi_fifo params -----
#modparam(“mi_fifo”, “fifo_name”, “/tmp/kamailio_fifo”)

#----- tm params -----

auto-discard branches from previous serial forking leg

modparam(“tm”, “failure_reply_mode”, 3)

default retransmission timeout: 30sec

modparam(“tm”, “fr_timer”, 30000)

default invite retransmission timeout after 1xx: 120sec

modparam(“tm”, “fr_inv_timer”, 120000)
modparam(“tm”, “ruri_matching”, 0)

#----- rr params -----

add value to ;lr param to cope with most of the UAs

modparam(“rr”, “enable_full_lr”, 1)

do not append from tag to the RR (no need for this script)

#!ifdef WITH_ASTERISK
modparam(“rr”, “append_fromtag”, 1)
#!else
modparam(“rr”, “append_fromtag”, 0)
#!endif

#----- registrar params -----
modparam(“registrar”, “method_filtering”, 1)
/* uncomment the next line to disable parallel forking via location */

modparam(“registrar”, “append_branches”, 0)

/* uncomment the next line not to allow more than 10 contacts per AOR */
#modparam(“registrar”, “max_contacts”, 10)

max value for expires of registrations

modparam(“registrar”, “max_expires”, 3600)

set it to 1 to enable GRUU

modparam(“registrar”, “gruu_enabled”, 0)

#----- acc params -----
/* what special events should be accounted ? /
modparam(“acc”, “early_media”, 0)
modparam(“acc”, “report_ack”, 0)
modparam(“acc”, “report_cancels”, 0)
/
by default ww do not adjust the direct of the sequential requests.
if you enable this parameter, be sure the enable “append_fromtag”
in “rr” module /
modparam(“acc”, “detect_direction”, 0)
/
account triggers (flags) /
modparam(“acc”, “log_flag”, FLT_ACC)
modparam(“acc”, “log_missed_flag”, FLT_ACCMISSED)
modparam(“acc”, “log_extra”,
“src_user=$fU;src_domain=$fd;src_ip=$si;”
“dst_ouser=$tU;dst_user=$rU;dst_domain=$rd”)
modparam(“acc”, “failed_transaction_flag”, FLT_ACCFAILED)
/
enhanced DB accounting */
#!ifdef WITH_ACCDB
modparam(“acc”, “db_flag”, FLT_ACC)
modparam(“acc”, “db_missed_flag”, FLT_ACCMISSED)
modparam(“acc”, “db_url”, DBURL)
modparam(“acc”, “db_extra”,
“src_user=$fU;src_domain=$fd;src_ip=$si;”
“dst_ouser=$tU;dst_user=$rU;dst_domain=$rd”)
#!endif

----- usrloc params -----

/* enable DB persistency for location entries */
#!ifdef WITH_USRLOCDB
modparam(“usrloc”, “db_url”, DBURL)
modparam(“usrloc”, “db_mode”, 2)
modparam(“usrloc”, “use_domain”, MULTIDOMAIN)
modparam(“usrloc”, “matching_mode”, 1)
modparam(“usrloc”, “db_insert_update”, 1)
#!endif

#----- auth_db params -----
#!ifdef WITH_AUTH

modparam(“auth_db”, “db_url”, DBURL)
modparam(“auth_db”, “calculate_ha1”, yes)
modparam(“auth_db”, “load_credentials”, “”)

#!ifdef WITH_ASTERISK
modparam(“auth_db”, “user_column”, “username”)
modparam(“auth_db”, “password_column”, “secret”)
modparam(“auth_db”, “db_url”, DBASTURL)
modparam(“auth_db”, “version_table”, 0)
#!else
modparam(“auth_db”, “db_url”, DBURL)
modparam(“auth_db”, “password_column”, “password”)
modparam(“auth_db”, “use_domain”, MULTIDOMAIN)
#!endif

#----- permissions params -----
#!ifdef WITH_IPAUTH
modparam(“permissions”, “db_url”, DBURL)
modparam(“permissions”, “db_mode”, 1)
modparam(“permissions”, “trusted_table”, “trusted”)
#!endif

#!endif

#----- alias_db params -----
#!ifdef WITH_ALIASDB
modparam(“alias_db”, “db_url”, DBURL)
modparam(“alias_db”, “use_domain”, MULTIDOMAIN)
#!endif

#----- speedial params -----
#!ifdef WITH_SPEEDDIAL
modparam(“speeddial”, “db_url”, DBURL)
modparam(“speeddial”, “use_domain”, MULTIDOMAIN)
#!endif

#----- domain params -----
#!ifdef WITH_MULTIDOMAIN
modparam(“domain”, “db_url”, DBURL)
#register callback to match myself condition with domains list
modparam(“domain”, “register_myself”, 1)
#!endif

#!ifdef WITH_PRESENCE
#----- presence params -----
modparam(“presence”, “db_url”, DBURL)

#----- presence_xml params -----
modparam(“presence_xml”, “db_url”, DBURL)
modparam(“presence_xml”, “force_active”, 1)
#!endif

#!ifdef WITH_NAT
#----- rtpproxy params -----
modparam(“rtpproxy”, “rtpproxy_sock”, “udp: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”)

#params needed for NAT traversal in other modules
modparam(“nathelper|registrar”, “received_avp”, “$avp(RECEIVED)”)
modparam(“usrloc”, “nat_bflag”, FLB_NATB)
#!endif

#!ifdef WITH_TLS
#----- tls params -----
modparam(“tls”, “config”, “/usr/local/etc/kamailio/tls.cfg”)
#!endif

#!ifdef WITH_ANTIFLOOD
#----- pike params -----
modparam(“pike”, “sampling_time_unit”, 2)
modparam(“pike”, “reqs_density_per_unit”, 16)
modparam(“pike”, “remove_latency”, 4)

#----- htable params -----

ip ban htable with autoexpire after 5 minutes

#modparam(“htable”, “htable”, “ipban=>size=8;autoexpire=300;”)
modparam(“htable”, “htable”, “stats=>size=6;”)

#!endif

#!ifdef WITH_XMLRPC
#----- xmlrpc params -----
modparam(“xmlrpc”, “route”, “XMLRPC”);
modparam(“xmlrpc”, “url_match”, “^/RPC”)
#!endif

#!ifdef WITH_DEBUG
#----- debugger params -----
#modparam(“debugger”, “cfgtrace”, 1)
#modparam(“debugger”, “breakpoint”, 1)
modparam(“debugger”, “log_level_name”, “exec”)
#!endif

####### Routing Logic ########

#Main SIP request routing logic
#-processing of any incoming SIP request starts with this route
#-note: this is the same as route { … }

request_route {

            route(DISPATCH);

            # per request initial checks
            route(REQINIT);

            # NAT detection
            route(NATDETECT);

            #handle requests within SIP dialogs
            route(WITHINDLG);

            ###only initial requests (no To tag)

            if(is_method("OPTIONS"))
            {
            sl_send_reply("200","Keepalive");

           exit;
    }
            if(is_method("NOTIFY"))
            {
            sl_send_reply("200","OK");

            exit;
    }

            #CANCEL processing
            if (is_method("CANCEL"))
            {
                            if (t_check_trans())
                                            t_relay();
                            exit;
            }

            t_check_trans();

            #authentication

            route(AUTH);

            #record routing for dialog forming requests (in case they are routed)
            #-remove preloaded route headers
            remove_hf("Route");

            if (is_method("INVITE|SUBSCRIBE"))
                            record_route();

            # account only INVITEs
            if (is_method("INVITE"))
            {      

                            setflag(FLT_ACC); # do accounting
            }


            #dispatch requests to foreign domains
            route(SIPOUT);

            ###requests for my local domains

            #handle presence related requests
            route(PRESENCE);

            #handle registrations
            route(REGISTRAR);

            if ($rU==$null)
            {
                            # request with no Username in RURI
                            sl_send_reply("484","Address Incomplete");
                            exit;
            }

            #dispatch destinations to PSTN
            route(PSTN);

            #user location service
            route(LOCATION);

            route(RELAY);

}

route[RELAY] {

            #enable additional event routes for forwarded requests
            #-serial forking, RTP relaying handling, a.s.o.
            if (is_method("INVITE|SUBSCRIBE")) {
                            t_on_branch("MANAGE_BRANCH");
                            t_on_reply("MANAGE_REPLY");
            }
            if (is_method("INVITE")) {
                            t_on_failure("MANAGE_FAILURE");
            }

            if (!t_relay()) {
                            sl_reply_error();
            }
            exit;

}

#Per SIP request initial checks
route[REQINIT] {
#!ifdef WITH_ANTIFLOOD
# flood dection from same IP and traffic ban for a while
# be sure you exclude checking trusted peers, such as pstn gateways
# - local host excluded (e.g., loop to self)
if(src_ip!=myself)
{
if($sht(ipban=>$si)!=$null)
{
# ip is already blocked
xdbg(“request from blocked IP - $rm from $fu (IP:$si:$sp)\n”);
exit;
}
if (!pike_check_req())
{
xlog(“L_ALERT”,“ALERT: pike blocking $rm from $fu (IP:$si:$sp)\n”);
$sht(ipban=>$si) = 1;
exit;
}
}
#!endif

            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;
            }

}

#Handle requests within SIP dialogs
route[WITHINDLG] {
if (has_totag()) {
# sequential request withing a dialog should
# take the path determined by record-routing
if (loose_route()) {
if (is_method(“BYE”)) {
setflag(FLT_ACC); # do accounting …
setflag(FLT_ACCFAILED); # … even if the transaction fails
}
if ( is_method(“ACK”) ) {
# ACK is forwarded statelessy
route(NATMANAGE);
}
route(RELAY);
} else {
if (is_method(“SUBSCRIBE”) && uri == myself) {
# in-dialog subscribe requests
route(PRESENCE);
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
t_relay();
exit;
} else {
# ACK without matching transaction … ignore and discard
exit;
}
}
sl_send_reply(“404”,“Not here”);
}
exit;
}
}

#Handle SIP registrations
route[REGISTRAR] {
if (is_method(“REGISTER”))
{
if(isflagset(FLT_NATS))
{
setbflag(FLB_NATB);
# uncomment next line to do SIP NAT pinging
## setbflag(FLB_NATSIPPING);
}
if (!save(“location”))
sl_reply_error();

#!ifdef WITH_ASTERISK
route(REGFWD);
#!endif

                            exit;
            }

}

#USER location service
route[LOCATION] {

#!ifdef WITH_SPEEDIAL
# search for short dialing - 2-digit extension
if(rU=~"^[0-9][0-9]")
if(sd_lookup(“speed_dial”))
route(SIPOUT);
#!endif

#!ifdef WITH_ALIASDB
# search in DB-based aliases
if(alias_db_lookup(“dbaliases”))
route(SIPOUT);
#!endif

#!ifdef WITH_ASTERISK
if(is_method(“INVITE”) && (!route(FROMASTERISK))) {
# if new call from out there - send to Asterisk
# - non-INVITE request are routed directly by Kamailio
# - traffic from Asterisk is routed also directy by Kamailio
append_hf(“FromIp: $src_ip\r\n”, “Call-ID”);
route(TOASTERISK);
exit;
}
#!endif

            $avp(oexten) = $rU;
            if (!lookup("location")) {
                            $var(rc) = $rc;
                            route(TOVOICEMAIL);
                            t_newtran();
                            switch ($var(rc)) {
                                            case -1:
                                            case -3:
                                                            send_reply("404", "Not Found");
                                                            exit;
                                            case -2:
                                                            send_reply("405", "Method Not Allowed");
                                                            exit;
                            }
            }

            # when routing via usrloc, log the missed calls also
            if (is_method("INVITE"))
            {
                            setflag(FLT_ACCMISSED);
            }

}

#Presence server route
route[PRESENCE] {
if(!is_method(“PUBLISH|SUBSCRIBE”))
return;

#!ifdef WITH_PRESENCE
if (!t_newtran())
{
sl_reply_error();
exit;
};

            if(is_method("PUBLISH"))
            {
                            handle_publish();
                            t_release();
            }
            else
            if( is_method("SUBSCRIBE"))
            {
                            handle_subscribe();
                            t_release();
            }
            exit;

#!endif

            # if presence enabled, this part will not be executed
            if (is_method("PUBLISH") || $rU==$null)
            {
                            sl_send_reply("404", "Not here");
                            exit;
            }
            return;

}

#Authentication route
route[AUTH] {
#!ifdef WITH_AUTH

#!ifdef WITH_ASTERISK
# do not auth traffic from Asterisk - trusted!
if(route(FROMASTERISK))
return;
#!endif

#!ifdef WITH_IPAUTH

            if((!is_method("REGISTER")) && allow_source_address())
            {      

                            # source IP allowed
                            return;
            }

if (is_method(“REGISTER”) || from_uri==myself){
if (!allow_trusted()) {
xlog(‘wokred here for ipauth check’);
sl_send_reply(“403”, “Forbidden”);
}
}

#!endif

            if (is_method("REGISTER") || from_uri==myself)
            {
                            # authenticate requests

#!ifdef WITH_ASTERISK

                            if (!auth_check("$fd", "sip_users", "1")) {

#!else
if (!auth_check("$fd", “subscriber”, “1”)) {
#!endif
auth_challenge("$fd", “0”);
exit;
}
# user authenticated - remove auth header
if(!is_method(“REGISTER|PUBLISH”))
consume_credentials();
}
# if caller is not local subscriber, then check if it calls
# a local destination, otherwise deny, not an open relay here
if (from_uri!=myself && uri!=myself)
{
sl_send_reply(“403”,“Not relaying”);
exit;
}

#!endif
return;
}

#Caller NAT detection route
route[NATDETECT] {
#!ifdef WITH_NAT
force_rport();
if (nat_uac_test(“19”)) {
if (is_method(“REGISTER”)) {
fix_nated_register();
} else {
fix_nated_contact();
}
setflag(FLT_NATS);
}
#!endif
return;
}

#RTPProxy control
route[NATMANAGE] {
#!ifdef WITH_NAT
if (is_request()) {
if(has_totag()) {
if(check_route_param(“nat=yes”)) {
setbflag(FLB_NATB);
}
}
}
if (!(isflagset(FLT_NATS) || isbflagset(FLB_NATB)))
return;

            rtpproxy_manage();

            if (is_request()) {
                            if (!has_totag()) {
                                            add_rr_param(";nat=yes");
                            }
            }
            if (is_reply()) {
                            if(isbflagset(FLB_NATB)) {
                                            fix_nated_contact();
                            }
            }

#!endif
return;
}

#Routing to foreign domains
route[SIPOUT] {
if (!uri==myself)
{
append_hf(“P-hint: outbound\r\n”);
route(RELAY);
}
}

#PSTN GW routing
route[PSTN] {
#!ifdef WITH_PSTN
# check if PSTN GW IP is defined
if (strempty($sel(cfg_get.pstn.gw_ip))) {
xlog(“SCRIPT: PSTN rotuing enabled but pstn.gw_ip not defined\n”);
return;
}

            # route to PSTN dialed numbers starting with '+' or '00'
            #     (international format)
            # - update the condition to match your dialing rules for PSTN routing
            if(!($rU=~"^(\+|00)[1-9][0-9]{3,20}$"))
                            return;

            # only local users allowed to call
            if(from_uri!=myself) {
                            sl_send_reply("403", "Not Allowed");
                            exit;
            }

            $ru = "sip:" + $rU + "@" + $sel(cfg_get.pstn.gw_ip);

            route(RELAY);
            exit;

#!endif

            return;

}

#XMLRPC routing
#!ifdef WITH_XMLRPC
route[XMLRPC] {
# allow XMLRPC from localhost
if ((method==“POST” || method==“GET”)
&& (src_ip==127.0.0.1)) {
# close connection only for xmlrpclib user agents (there is a bug in
# xmlrpclib: it waits for EOF before interpreting the response).
if ($hdr(User-Agent) =~ “xmlrpclib”)
set_reply_close();
set_reply_no_connect();
dispatch_rpc();
exit;
}
send_reply(“403”, “Forbidden”);
exit;
}
#!endif

#route to voicemail server
route[TOVOICEMAIL] {
#!ifdef WITH_VOICEMAIL
if(!is_method(“INVITE”))
return;

            # check if VoiceMail server IP is defined
            if (strempty($sel(cfg_get.voicemail.srv_ip))) {
                            xlog("SCRIPT: VoiceMail rotuing enabled but IP not defined\n");
                            return;
            }
            if($avp(oexten)==$null)
                            return;

            $ru = "sip:" + $avp(oexten) + "@" + $sel(cfg_get.voicemail.srv_ip)
                                                            + ":" + $sel(cfg_get.voicemail.srv_port);
            route(RELAY);
            exit;

#!endif

            return;

}

#manage outgoing branches
branch_route[MANAGE_BRANCH] {
xdbg(“new branch [$T_branch_idx] to $ru\n”);
route(NATMANAGE);
}

#manage incoming replies
onreply_route[MANAGE_REPLY] {
xdbg(“incoming reply\n”);
if(status=~"[12][0-9][0-9]")
route(NATMANAGE);
}

#manage failure routing cases
failure_route[MANAGE_FAILURE] {
route(NATMANAGE);

            if (t_is_canceled()) {
                            exit;
            }
            if(t_check_status("401")) {
      uac_auth();
   }

#!ifdef WITH_BLOCK3XX
# block call redirect based on 3xx replies.
if (t_check_status(“3[0-9][0-9]”)) {
t_reply(“404”,“Not found”);
exit;
}
#!endif

#!ifdef WITH_VOICEMAIL
# serial forking
# - route to voicemail on busy or no answer (timeout)
if (t_check_status(“486|408”)) {
route(TOVOICEMAIL);
exit;
}
t_relay();
#!endif
}

#Test if coming from Asterisk
route[FROMASTERISK] {

if($si==$sel(cfg_get.asterisk.bindip)

&& $sp==$sel(cfg_get.asterisk.bindport))

return 1;

return -1;

            # dispatch: is this asterisk ip ?
            if (ds_is_from_list("1"))
                            return 1;
            return -1;

}

route[TOASTERISK] {
#$du = “sip:” + $sel(cfg_get.asterisk.bindip) + “:”+ $sel(cfg_get.asterisk.bindport);
#append_hf(“X-Asterisk-Context: dexter-phones\r\n”);
#route(RELAY);
#exit;
# select asterisk port
append_hf(“X-Asterisk-Context: dexter-phones\r\n”);
route(DISPATCH);
}

route[DISPATCH] {
# round robin dispatching on gateways group ‘1’
#xlog("<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>");

            #if (is_method("INVITE")) {
            # dst_select( "GROUP", "HASH METHOD")
            #ds_select_dst("1","4");
            #sl_send_reply("100","Trying");
           # forward();
           # exit();
            #}
    if (!ds_select_domain("1", "4")) {
      send_reply("404", "No destination");
      exit;
    }
    t_on_failure("RTF_DISPATCH");
            route(RELAY);
            exit;

}

route[REGFWD] {
if(!is_method(“REGISTER”))
{
return;
}

            $var(rip) = $sel(cfg_get.asterisk.bindip);
            $uac_req(method)="REGISTER";
            $uac_req(ruri)="sip:" + $var(rip) + ":" + $sel(cfg_get.asterisk.bindport);
            $uac_req(furi)="sip:" + $au + "@" + $var(rip);
            $uac_req(turi)="sip:" + $au + "@" + $var(rip);
            $uac_req(hdrs)="Contact: <sip:" + $au + "@" + $sel(cfg_get.kamailio.bindip) + ":" + $sel(cfg_get.kamailio.bindport) + ">\r\n";

            if($sel(contact.expires) != $null)
                            $uac_req(hdrs)= $uac_req(hdrs) + "Expires: " + $sel(contact.expires) + "\r\n";
            else
                            $uac_req(hdrs)= $uac_req(hdrs) + "Expires: " + $hdr(Expires) + "\r\n";
            uac_req_send();

}

And also have set trunk in ASTERISK sip.conf

register => kamailioSIP:XXXX@KamailioIP:5060

[kamailio]
type=friend
host= KamailioIP
port=5060
transport=udp
allow=all
allow=gsm
allow=alaw,ulaw
insecure=invite,port
Permit = 0.0.0.0/0.0.0.0
sipdebug=yes
username=kamailioSIP
canreinvite=no
secret=XXXX
qualify=yes
dtmfmode=auto

after all the above configs when i Register my asterisk devices with kamailioIP (and I am able to do this)
Devices are getting register with the asterisk from with kamailioIP asterisk -r : (here 8101 and 8100 is registered with Kamailio IP )

[Nov 9 10:36:02] – Registered SIP ‘8101’ at XX.XX.XX.95:5060
[Nov 9 10:36:02] – Unregistered SIP ‘8101’
[Nov 9 10:36:03] – Registered SIP ‘8101’ at XX.XX.XX…95:5060
[Nov 9 10:36:03] == Manager ‘listencron’ logged on from 127.0.0.1
[Nov 9 10:36:04] == Manager ‘sendcron’ logged off from 127.0.0.1
[Nov 9 10:36:07] – Unregistered SIP ‘8100’
[Nov 9 10:36:09] – Registered SIP ‘8100’ at XX.XX.XX…95:5060
[Nov 9 10:36:09] > Saved useragent “Z 3.15.40006 rv2.8.20” for peer 8100
[Nov 9 10:36:09] NOTICE[8453]: chan_sip.c:23869 handle_response_peerpoke: Peer ‘8100’ is now
Reachable. (51ms / 2000ms)

when i dial 8100 to 8101 i get in my asteris -r

NOTICE[8453][C-0000000b]: chan_sip.c:26002 handle_request_invite: Call from ‘8101’ (95.217.223.95:5060) to extension ‘8100’ rejected because extension not found in context ‘none-dial’.

and not able to call extension to extension.

PLESE HELP!! any help will be appreciated :slight_smile:

I will be looking forward for help,
Thanks in advance :slight_smile:

In our setup, we do not require authentication from Kamailio, this works fine… Also you need to set the context the calls coming from kamailio, should be processed in. Currently they are processed in the context none-dial

Just at a line with something like this, to the kamailio peer.
context=whatever-context-allows-you-to-dial-8100

If that does not work, try changing the permit line to the IP of kamailio, and removing the username and secret.

1 Like

Hi Chano, Thanks a lot for your response. :slight_smile:

actually I am doing it for the first time and, as I said before, don’t have exact idea about it that how stuff goes on…

i have researched and got kamailio configured and succeeded till now that my devices are registering from kamailio IP using asterisk creds.

please Help me in this as you mentioned
“In our setup, we do not require authentication from Kamailio, this works fine.”

what should I add or remove from my kamailio.cfg file that as you are doing so it do not require authentication from Kamailio… if you can please share your kamailio.cfg file or any pointers.

and the second thing, i do not have anything in my asterisk exensions.conf named
“none-dial” no idea from where it is coming from…so please also help me in this too… which dialplan I have to put in so that i can do calling successfully.

I have tried doing changing the permit line to the IP of kamailio, and removing the username and secret.

Please Help me in doing this.

Your help would me much appreciated.
Thanks in advance

I have NO idea in regards to the Kamailio part, I’ve only made minor changes to our configuration.

But before migrating to pjsip, I had the following in my sip.conf:

[general]
context=default
allowoverlap=no
udpbindaddr=0.0.0.0
tcpenable=no
tcpbindaddr=0.0.0.0
srvlookup=no
vmexten=*902
disallow=all
allow=alaw
language=en
notifyhold=yes
notifycid=yes
callcounter=yes
useragent=<Some custom user agent>
minexpiry=30
fromdomain=<Asterisk hostname>
nat=force_rport,comedia
force_rport=yes
t38pt_udptl=yes

[trunks](!)
insecure=port,invite
host=<Kamailio IP>
nat=force_rport,comedia
canreinvite=no
type=friend
language=en
dtmfmode=auto
dtmf=auto
force_rport=yes
t38pt_udptl=yes

[inboundTrunk](trunks)
context=general_inboundRouting
accountcode=inboundTrunk

Of cause there were more, but this is the part that allowed incoming calls to Asterisk to be processed. They were processed in the general_inboundRouting context.

On the Kamailio side, everything was just routed to the Asterisk server for processing.

In our particular setup, our customers register to the Asterisk server, with their extensions, Asterisk then handles calls between extensions, while Kamailio handles outbound calls, either to other customers, or the public phone network.

As I see it you seem to try to make Kamailio handle your internal calls between extensions as well? Or are the 8xxx numbers just placeholders and intended to be real numbers in the end?

Hi,
Thanks for sharing your sip.conf file.
But I think I have issue in my dialplan, probably I have not set extn in my extension.conf. And
Have not much idea about it.
If you can please share your extension.conf.

Bcz now when I dial 101 which I have set for a m Media file. And when I dial from my device and which is registered from kamailio IP and I am able to hear that media.

Now I am not sure where I am doing wrong in the extension.conf which is for calling. Please if you can go through my extension.conf and point out where I am putting wrong extn and what should I put for internally calling and also for conference.

You help is much appreciated.
Thanks in advance for your help.

this is now in my extensions.conf i have set the name with none-dial

[none-dial]; I added these below linesexten => _XXXX,1,Answer()
exten => _XXXX,n,Playback(demo-congrats)
exten => _XXXX,n,Hangup()exten => _XXXX,2,NoOp(internal context called on Server A to {EXTEN}, CALLERID_num {CALLERID(num)}, CALLERID_num_f2 {CALLERID(num):0:2}) exten => _XXXX,3,Dial(SIP/{EXTEN},15)exten => s,n,Dial(SIP/{[EXTEN}@95.217.223.95:5060](http://EXTEN}@95.217.223.95:5060),,) exten => s,n,Hangup()exten => _XXXX,1,AGI(agi://127.0.0.1:4577/call_log) exten => _XXXX,2,Dial(SIP/kamailio/{EXTEN}@95.217.223.95:5060,55,To) ; any call forward back to kamailio
exten => _XXXX,3,Hangup()exten => _XXXXXXXXXX.,1,AGI(agi://127.0.0.1:4577/call_log)
exten => _XXXXXXXXXX.,2,Dial(SIP/{[EXTEN:1}@95.217.223.95:5060](http://EXTEN:1}@95.217.223.95:5060),,tTo) exten => _XXXXXXXXXX.,3,Hangup()exten => _sXXXX.,1,AGI(agi://127.0.0.1:4577/call_log) exten => _sXXXX.,2,Dial(SIP/{EXTEN:1}@95.217.223.95:5060,tTo)
exten => _sXXXX.,3,Hangup()exten => _sXXXXXXXXXX,1,AGI(agi-DID_route.agi)
exten => _sXXXXXXXXXX,2,Dial({Kamailio}/{EXTEN:1},tTo)
exten => _sXXXXXXXXXX,3,Hangup()exten => _sXXXXXXXXXX,n,Dial(sip/{EXTEN:1}@kamailio,55,o)exten => s,1,NoOp({SIP_HEADER(TO)})exten => s,n,Set(DN={SIP_HEADER(TO)}) exten => s,n,Set(DN={CUT(DN,:,2)})
exten => s,n,Set(DN={CUT(DN,@,1)}) exten => s,n,Set(DN={STRREPLACE(DN,+,00)})
exten => s,n,Goto(trunkinbound,{DN},1)exten => s,1,Verbose(4,calling user on kamailio) exten => s,n,Dial(SIP/{EXTEN}@kamailio,)
exten => s,n,Hangup(); I added these lines till here

and this is my current sip.conf kamailio truck

register => kamailio@95.217.223.95:5060[kamailio]
type=friend
host=95.217.223.95
port=5060
transport=udp
disallow=all
allow=all
allow=gsm
allow=g729
allow=alaw
allow=ulaw
context=none-dial
insecure=invite,port
Permit=95.217.223.95
sipdebug=yes
username=kamailio
;secret=vici1234
canreinvite=no
qualify=no
dtmfmode=auto
srvlookup=yes
canreinvite=no

please go through this and lemme know what is crap here and what to add and remove in order to make calls…
this below extn is working currently, ans i am able to listen the media from my device which is registered from kamailio IP
exten => _XXXX,1,Answer()
exten => _XXXX,n,Playback(demo-congrats)
exten => _XXXX,n,Hangup()

Ok, just cleaned up what you posted. If you click the “</>” icon in the editor, and past your dial plan within the code block, it’s much easier to read.

exten => _XXXX,1,Answer()
exten => _XXXX,n,Playback(demo-congrats)
exten => _XXXX,n,Hangup()
exten => _XXXX,2,NoOp(internal context called on Server A to {EXTEN}, CALLERID_num {CALLERID(num)}, CALLERID_num_f2 {CALLERID(num):0:2}) 
exten => _XXXX,3,Dial(SIP/{EXTEN},15)

exten => s,n,Dial(SIP/{[EXTEN}@95.217.223.95:5060](http://EXTEN}@95.217.223.95:5060),,) 
exten => s,n,Hangup()

exten => _XXXX,1,AGI(agi://127.0.0.1:4577/call_log) 
exten => _XXXX,2,Dial(SIP/kamailio/{EXTEN}@95.217.223.95:5060,55,To) ; any call forward back to kamailio
exten => _XXXX,3,Hangup()

exten => _XXXXXXXXXX.,1,AGI(agi://127.0.0.1:4577/call_log)
exten => _XXXXXXXXXX.,2,Dial(SIP/{[EXTEN:1}@95.217.223.95:5060](http://EXTEN:1}@95.217.223.95:5060),,tTo) 
exten => _XXXXXXXXXX.,3,Hangup()

exten => _sXXXX.,1,AGI(agi://127.0.0.1:4577/call_log) 
exten => _sXXXX.,2,Dial(SIP/{EXTEN:1}@95.217.223.95:5060,tTo)
exten => _sXXXX.,3,Hangup()

exten => _sXXXXXXXXXX,1,AGI(agi-DID_route.agi)
exten => _sXXXXXXXXXX,2,Dial({Kamailio}/{EXTEN:1},tTo)
exten => _sXXXXXXXXXX,3,Hangup()
exten => _sXXXXXXXXXX,n,Dial(sip/{EXTEN:1}@kamailio,55,o)

exten => s,1,NoOp({SIP_HEADER(TO)})
exten => s,n,Set(DN={SIP_HEADER(TO)}) 
exten => s,n,Set(DN={CUT(DN,:,2)})
exten => s,n,Set(DN={CUT(DN,@,1)}) 
exten => s,n,Set(DN={STRREPLACE(DN,+,00)})
exten => s,n,Goto(trunkinbound,{DN},1)
exten => s,1,Verbose(4,calling user on kamailio) 
exten => s,n,Dial(SIP/{EXTEN}@kamailio,)
exten => s,n,Hangup(); I added these lines till here

If the above is indeed your current dial plan it’s mound to cause problems for you.

Lets have a look at this section first

exten => _XXXX,1,Answer()
exten => _XXXX,n,Playback(demo-congrats)
exten => _XXXX,n,Hangup()
exten => _XXXX,2,NoOp(internal context called on Server A to {EXTEN}, CALLERID_num {CALLERID(num)}, CALLERID_num_f2 {CALLERID(num):0:2}) 
exten => _XXXX,3,Dial(SIP/{EXTEN},15)

The first line tells asterisk at priority 1, to answer the line for extension _XXXX.
The next line with priority n becomes priority 2, and plays an audio file
Next line, priority 3, will hangup the call.
Then in the 4th line, you set priority 2 to log som text to screen using the NoOp app (I prefer LOG() but whatever). This line OVERWRITES the previous priority 2!
The next line, line 5 you overwrite priority 3 with the Dial command. The resulting dial plan in asterisk, from my understanding, will be this:

exten => _XXXX,1,Answer()
exten => _XXXX,2,NoOp(internal context called on Server A to {EXTEN}, CALLERID_num {CALLERID(num)}, CALLERID_num_f2 {CALLERID(num):0:2}) 
exten => _XXXX,3,Dial(SIP/{EXTEN},15)

That is, until we process the rest of the dial plan, where you once again, overwrite all 3 priorities of extension _XXXX, and end up with this:

exten => _XXXX,1,AGI(agi://127.0.0.1:4577/call_log) 
exten => _XXXX,2,Dial(SIP/kamailio/{EXTEN}@95.217.223.95:5060,55,To) ; any call forward back to kamailio
exten => _XXXX,3,Hangup()

Same for your s extension, btw.

Also any AGI script you throw in to the mix, will make dial plan problems harder to diagnose.

If you are not completely confident with how Asterisk works, and how to write a proper dial plan, that should be where to start. Make a basic, version, that just dials whatever you want, then add whatever vicidicl functionality you want.

Another thing I notices, is the missing dollar sign in front of every variable, I assume this to be a. “Feature” of the forum software, if not, you need to add it.

To verify your dial plan looks like you expect, when loaded into asterisk, you can use dialplan show from the asterisk cli. If you want to only see a specifik context use dialplan show context and if you want to see how Asterisk will process a dialed extension in the specific content, use dialplan show xxxx@context

I suppose the dialplan above, is compiled from snippets copy and pasted from multiple sources, and not a complete example?

As for sharing my own extensions.conf, it will be impossible, as we are talking about 100s of lines. Most of then only relevant to our specific setup. Also I migrated everything away from chan_sip about a year ago, and as such have not actual configuration left. (Config files are generated by custom software, and as such I only have the templates, that makes little sense as a generalized example.)

This is a very common effect of failing to use </>.

Hi, Thank you So much for the detailed Response bro, I read it out and for sure gonna learn this all… I appreciate it.

and yes, you are right I don’t have much idea about the dialplans i have in my extensions.conf.

but today i researched something else and tried it, i got some success in this…
(what i did was to put some of the conf dialplans from general context to my none-dial context) and i successfully got call when i login agent and able to listen the
“conf-onlyperson.gsm” the only person audio… and also i was able to call 8101 to 8102 (but i dont know why not able to call vice versa)

but the issue now is (i suppose) now only at asterisk side because now again i am not able to call which was working before please help me in this and if you have idea why the behavior is intermittent so please point out the stuff…Preformatted text

and thanks a lot for the tip to post code in a better format… i had no idea about it as it is my first time posting here, and i am gonna remember this ahead. :slight_smile:

my extensions.conf look like this now

[none-dial]

include => vicidial-auto

exten => _1122,1,Answer()
exten => _1122,n,Playback(demo-congrats)
exten => _1122,n,Hangup()

exten => _XXXXXXXXXX,1,AGI(agi-DID_route.agi)
exten => s,1,AGI(agi-DID_route.agi)


; Local blind monitoring
;exten => _08600XXX,1,Dial(${TRUNKblind}/6${EXTEN:1},55,To)
;exten => _08600XXX,n,Hangup()



; Local agent alert extensions
exten => _8600XXX*.,1,AGI(agi-VDADfixCXFER.agi)
exten => _8600XXX*.,n,Hangup()
exten => _78600XXX*.,1,AGI(agi-VDADfixCXFER.agi)
exten => _78600XXX*.,n,Hangup()

; astGUIclient conferences
exten => _86000[0-4]X,1,Meetme(${EXTEN},q)
exten => _86000[0-4]X,n,Hangup()

; VICIDIAL conferences
exten => _86000[5-9]X,1,Meetme(${EXTEN},F)
exten => _86000[5-9]X,n,Hangup()
exten => _8600[1-2]XX,1,Meetme(${EXTEN},F)
exten => _8600[1-2]XX,n,Hangup()

exten => _XXXX,1,AGI(agi://127.0.0.1:4577/call_log)
exten => _XXXX,2,Dial(${KAMAILIOTRUNK}/${EXTEN},,To) ; any call forward back to kamailio
exten => _XXXX,3,Hangup()

;exten => _XXXX,2,NoOp(internal context called on Server A to ${EXTEN},
;CALLERID_num ${CALLERID(num)}, CALLERID_num_f2 ${CALLERID(num):0:2})
;exten => _XXXX,3,Dial(SIP/${EXTEN},15)

exten => s,n,Dial(SIP/${EXTEN},,)
exten => s,n,Hangup()

; MeetMe Adjustment Extensions
exten => _X48600XXX,1,MeetMeAdmin(${EXTEN:2},T,${EXTEN:0:1})
exten => _X48600XXX,2,Hangup()

exten => _X38600XXX,1,MeetMeAdmin(${EXTEN:2},t,${EXTEN:0:1})
exten => _X38600XXX,2,Hangup()

exten => _X28600XXX,1,MeetMeAdmin(${EXTEN:2},m,${EXTEN:0:1})
exten => _X28600XXX,2,Hangup()

exten => _X18600XXX,1,MeetMeAdmin(${EXTEN:2},M,${EXTEN:0:1})
exten => _X18600XXX,2,Hangup()

exten => _55558600XXX,1,MeetMeAdmin(${EXTEN:4},K)
exten => _55558600XXX,2,Hangup()

exten => _8[0-2]XX,1,Meetme(8600${EXTEN:1},mqX) ; Listen
exten => _8[0-2]XX,n,Hangup()
exten => _99[0-2]XX,1,Meetme(8600${EXTEN:2},X)  ; Barge
exten => _99[0-2]XX,n,Hangup()

; quiet entry and leaving conferences for VICIDIAL (inbound announce, SendDTMF and ring-agent)
exten => _78600XXX,1,Meetme(${EXTEN:1},Fq)
exten => _78600XXX,n,Hangup()

; quiet monitor-only extensions for meetme rooms (for room managers)
exten => _68600XXX,1,Meetme(${EXTEN:1},Fmq)
exten => _68600XXX,n,Hangup()

; Asterisk 1.8 workaround
exten => _58600XXX,1,Meetme(${EXTEN:1},Fmq)
exten => _58600XXX,n,Hangup()

; quiet monitor-only entry and leaving conferences for VICIDIAL (recording)
exten => _558600XXX,1,Meetme(${EXTEN:2},Fmq)
exten => _558600XXX,n,Hangup()

; voicelab exten
exten => _86009XX,1,Meetme(${EXTEN},Fmq)
; voicelab exten moderator
exten => _986009XX,1,Meetme(${EXTEN:1})

and now my sip.conf is

[kamailio]
type=friend
host=95.217.223.95
port=5060
transport=udp
disallow=all
allow=all
allow=gsm
allow=g729
allow=alaw
allow=ulaw
context=none-dial
insecure=invite,port
Permit=95.217.223.95
sipdebug=yes
canreinvite=no
dtmfmode=auto
srvlookup=yes
canreinvite=no

these are the logs in my asterisk -r while i am dialing and calling not working

[Nov 11 13:33:12]     -- Registered SIP '8101' at 175.107.201.168:61846
[Nov 11 13:33:54]     -- Registered SIP '8101' at 88.198.141.166:61846
[Nov 11 13:33:57]     -- Unregistered SIP '8101'
[Nov 11 13:33:59]     -- Registered SIP '8101' at 88.198.141.166:61846
[Nov 11 13:33:59]     -- Unregistered SIP '8101'
[Nov 11 13:34:00]     -- Registered SIP '8101' at 88.198.141.166:61846
[Nov 11 13:34:01]   == Manager 'sendcron' logged on from 127.0.0.1
[Nov 11 13:34:01]   == Manager 'sendcron' logged off from 127.0.0.1
[Nov 11 13:34:01]   == Manager 'sendcron' logged on from 127.0.0.1
[Nov 11 13:34:04]   == Manager 'sendcron' logged off from 127.0.0.1
[Nov 11 13:34:05]     -- Unregistered SIP '8100'
[Nov 11 13:34:06]     -- Registered SIP '8100' at 192.168.0.101:56643
[Nov 11 13:34:06]        > Saved useragent "Z 3.15.40006 rv2.8.20" for peer 8100
[Nov 11 13:34:06]     -- Registered SIP '8101' at 175.107.201.168:61846
[Nov 11 13:34:16]     -- Unregistered SIP '8102'
[Nov 11 13:34:25]   == Manager 'sendcron' logged on from 127.0.0.1
[Nov 11 13:34:25] NOTICE[7689][C-00000001]: channel.c:5690 __ast_request_and_dial: Unable to request channel SIP/8101
[Nov 11 13:34:26]   == Manager 'sendcron' logged off from 127.0.0.1
[Nov 11 13:34:38]   == Manager 'sendcron' logged on from 127.0.0.1
[Nov 11 13:34:38]   == Manager 'sendcron' logged on from 127.0.0.1
[Nov 11 13:34:38]     -- Executing [55558600054@default:1] MeetMeAdmin("Local/55558600054@default-00000000;2", "8600054,K") in new stack
[Nov 11 13:34:38] WARNING[7709][C-00000002]: app_meetme.c:5053 admin_exec: Conference number '8600054' not found!
[Nov 11 13:34:38]     -- Executing [55558600054@default:2] Hangup("Local/55558600054@default-00000000;2", "") in new stack
[Nov 11 13:34:38]   == Spawn extension (default, 55558600054, 2) exited non-zero on 'Local/55558600054@default-00000000;2'
[Nov 11 13:34:38]     -- Executing [h@default:1] AGI("Local/55558600054@default-00000000;2", "agi://127.0.0.1:4577/call_log--HVcauses--PRI-----NODEBUG-----16---------------") in new stack
[Nov 11 13:34:38]     -- <Local/55558600054@default-00000000;2>AGI Script agi://127.0.0.1:4577/call_log--HVcauses--PRI-----NODEBUG-----16--------------- completed, returning 0
[Nov 11 13:34:39]   == Manager 'sendcron' logged off from 127.0.0.1
[Nov 11 13:34:39]   == Manager 'sendcron' logged off from 127.0.0.1
[Nov 11 13:34:48]   == Manager 'sendcron' logged on from 127.0.0.1
[Nov 11 13:34:48] NOTICE[7726][C-00000003]: channel.c:5690 __ast_request_and_dial: Unable to request channel SIP/8102
[Nov 11 13:34:49]   == Manager 'sendcron' logged off from 127.0.0.1
[Nov 11 13:34:54]     -- Registered SIP '8101' at 88.198.141.166:61846
[Nov 11 13:35:00]     -- Registered SIP '8101' at 175.107.201.168:61846
[Nov 11 13:35:02]   == Manager 'sendcron' logged on from 127.0.0.1
[Nov 11 13:35:02]   == Manager 'sendcron' logged on from 127.0.0.1
[Nov 11 13:35:02]   == Manager 'sendcron' logged off from 127.0.0.1
[Nov 11 13:35:04]   == Manager 'sendcron' logged off from 127.0.0.1
[Nov 11 13:35:37]     -- Registered SIP '8102' at 192.168.0.101:51817
[Nov 11 13:35:37]        > Saved useragent "Bria release 6.0.1 stamp 102003" for peer 8102
[Nov 11 13:35:37]     -- Unregistered SIP '8102'
[Nov 11 13:35:38]     -- Registered SIP '8102' at 88.198.141.166:51817
[Nov 11 13:35:42] NOTICE[5105]: chan_sip.c:29904 sip_poke_noanswer: Peer '8102' is now UNREACHABLE!  Last qualify: 0
[Nov 11 13:35:43]   == Manager 'sendcron' logged on from 127.0.0.1
[Nov 11 13:35:43]   == Manager 'sendcron' logged on from 127.0.0.1
[Nov 11 13:35:43]     -- Executing [55558600056@default:1] MeetMeAdmin("Local/55558600056@default-00000001;2", "8600056,K") in new stack
[Nov 11 13:35:43] WARNING[7849][C-00000004]: app_meetme.c:5053 admin_exec: Conference number '8600056' not found!
[Nov 11 13:35:43]     -- Executing [55558600056@default:2] Hangup("Local/55558600056@default-00000001;2", "") in new stack
[Nov 11 13:35:43]   == Spawn extension (default, 55558600056, 2) exited non-zero on 'Local/55558600056@default-00000001;2'
[Nov 11 13:35:43]     -- Executing [h@default:1] AGI("Local/55558600056@default-00000001;2", "agi://127.0.0.1:4577/call_log--HVcauses--PRI-----NODEBUG-----16---------------") in new stack
[Nov 11 13:35:43]     -- <Local/55558600056@default-00000001;2>AGI Script agi://127.0.0.1:4577/call_log--HVcauses--PRI-----NODEBUG-----16--------------- completed, returning 0
[Nov 11 13:35:44]   == Manager 'sendcron' logged off from 127.0.0.1
[Nov 11 13:35:44]   == Manager 'sendcron' logged off from 127.0.0.1
[Nov 11 13:35:48]     -- Registered SIP '8101' at 88.198.141.166:61846
[Nov 11 13:35:50]   == Manager 'sendcron' logged on from 127.0.0.1
[Nov 11 13:35:50] NOTICE[7861][C-00000005]: channel.c:5690 __ast_request_and_dial: Unable to request channel SIP/8102
[Nov 11 13:35:51]   == Manager 'sendcron' logged off from 127.0.0.1
[Nov 11 13:35:55]     -- Registered SIP '8101' at 175.107.201.168:61846

and in my asterisk -r : "sip show peers " says

8100/8100                 192.168.0.101                            D  Auto (No)  No             61595    UNREACHABLE
8101/8101                 88.198.141.166                           D  Auto (No)  No             58293    UNREACHABLE
8102/8102                 88.198.141.166                           D  Auto (No)  No             57323    UNREACHABLE

and while kamailio peer looks fine in  "sip show peers " 

kamailio                  95.217.223.95                               Yes        Yes         A  5060     OK (54 ms)

these are the extensions i have registered with Kamailio IP , and i am still not able to make or receive call. Please Help me in this too.
Thanks in advance

It’s been a while since I used the sip module… I’ve switched to pjsip long ago. Therefore I’m not sure id the “UNREACHABLE” state won the peers, matters, or not.

But to move forward, you would first have to determine where the failure is.

If you do what I would expect, your extensions (8100, 8101, 8102) registers to the Asterisk server, and performs their calls there. Asterisk then uses Kamailio for outbound calls to the PSTN.

Calls local to Asterisk, should never leave Asterisk, unless you have a good reason (Eg. billing dependent on CDRs from Kamailio) and in that case, ONLY calls that needs to be routed for billing purposes, should be sent out of Asterisk. That is, calls between 8100, 8101 and 8102 should never leave Asterisk. From what you’ve written, I can’t really get an idea of how your signal flow is.

You make some calls to AGI scripts in the section posted above. These scripts are like black boxes, that can change internal state of Asterisk in almost anyway they want to, unless they are strictly needed to actually process the calls, you should take them out of the dial plan, until it’s working as expected, simply to make debugging much easier, when not having to worry what the AGI scripts may change.