<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"Trebuchet MS";
        panose-1:2 11 6 3 2 2 2 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.E-MailFormatvorlage19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="DE" link="blue" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal"><span style="mso-fareast-language:EN-US">Hello,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US">this looks somehow like a dialplan issue from Asterisk side:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="font-size:10.0pt;font-family:"Trebuchet MS",sans-serif;color:#333333"><br>
<span style="background:#ECF3F7">when i dial 8100 to 8101 i get in my asteris -r</span><br>
<br>
<span style="background:#ECF3F7">NOTICE[8453][C-0000000b]: chan_sip.c:26002 handle_request_invite: Call from '8101' (</span></span><span style="font-size:10.0pt;font-family:"Trebuchet MS",sans-serif;color:#333333;background:#ECF3F7"><a href="http://95.217.223.95:5060"><span lang="EN-GB">95.217.223.95:5060</span></a></span><span lang="EN-GB" style="font-size:10.0pt;font-family:"Trebuchet MS",sans-serif;color:#333333;background:#ECF3F7">)
 to extension '8100' rejected because extension not found in context 'none-dial'.</span><span lang="EN-GB" style="font-size:10.0pt;font-family:"Trebuchet MS",sans-serif;color:#333333"><br>
<br>
<span style="background:#ECF3F7">and not able to call extension to extension,</span></span><span lang="EN-GB">  </span><span lang="EN-GB" style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US">See if you find something in the net with the quoted error message. Maybe if the issue is more from Asterisk side, try with a simple example without the Kamailio and then adding the
 Kamailio again when its works from Asterisk side.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US">Cheers,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US">Henning<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US">-- <o:p>
</o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US">Henning Westerholt –
</span><span style="mso-fareast-language:EN-US"><a href="https://skalatan.de/blog/"><span lang="EN-GB" style="color:#0563C1">https://skalatan.de/blog/</span></a></span><span lang="EN-GB" style="mso-fareast-language:EN-US"><o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US">Kamailio services –
</span><span style="mso-fareast-language:EN-US"><a href="https://gilawa.com/"><span lang="EN-GB" style="color:#0563C1">https://gilawa.com</span></a></span><span style="mso-fareast-language:EN-US">
<span lang="EN-GB"><o:p></o:p></span></span></p>
<p class="MsoNormal"><span lang="EN-GB" style="mso-fareast-language:EN-US"><o:p> </o:p></span></p>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin-left:35.4pt"><b>From:</b> sr-users <sr-users-bounces@lists.kamailio.org>
<b>On Behalf Of </b>Usama Shaikh<br>
<b>Sent:</b> Monday, November 9, 2020 6:16 PM<br>
<b>To:</b> sr-users@lists.kamailio.org<br>
<b>Subject:</b> [SR-Users] Having trouble Setup Kamailio as a load balancer for Asterisk servers using module dispatcher<o:p></o:p></p>
</div>
<p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><span style="font-size:10.0pt;font-family:"Trebuchet MS",sans-serif;color:black;background:#E1EBF2">Hello Everyone.</span><span style="font-size:10.0pt;font-family:"Trebuchet MS",sans-serif;color:black"><br>
<br>
<span style="background:#E1EBF2">I am having trouble to setting up kamailio for load balancing for asterisk servers.</span><br>
<br>
<span style="background:#E1EBF2">I am using module dispatcher for load balancing AND two different servers for kamailio and asterisk.</span><br>
<br>
<span style="background:#E1EBF2">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…</span><br>
<span style="background:#E1EBF2">using MariaDB MySQL for the dispatcher data.</span><br>
<br>
<span style="background:#E1EBF2">Simply I want to do is :</span><br>
<br>
<span style="background:#E1EBF2">1. Register my asterisk devices with kamailioIP (and I am able to do this using below configs)</span><br>
<span style="background:#E1EBF2">Devices are getting register with the asterisk from with kamailioIP</span><br>
<br>
<span style="background:#E1EBF2">2. I want to receive calls on the registered devices with KamailioIP (and i am not able to do this)</span><br>
<br>
<span style="background:#E1EBF2">WORK FLOW:</span><br>
<br>
<span style="background:#E1EBF2">KAMAILIO IP = XX.XX.XX.95 on port 5060 and Asterisk IP = XX.XX.XX.164 on port 5060</span><br>
<br>
<span style="background:#E1EBF2">SIP Device(ZOIPER) -------->>>>KAMAILIO SERVER(device register/load balancer)--------->>> ASTERISK SERVER</span><br>
<br>
<span style="background:#E1EBF2">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…</span><br>
<br>
<span style="background:#E1EBF2">my kamailio.cfg</span><br>
<br>
<span style="background:#E1EBF2">#!KAMAILIO</span><br>
<br>
<span style="background:#E1EBF2">#!define WITH_MYSQL</span><br>
<span style="background:#E1EBF2">#!define WITH_AUTH</span><br>
<span style="background:#E1EBF2">#!define WITH_ASTERISK</span><br>
<span style="background:#E1EBF2">#define WITH_NAT</span><br>
<span style="background:#E1EBF2">#!define WITH_DEBUG</span><br>
<span style="background:#E1EBF2">#!define WITH_USRLOCDB</span><br>
<br>
<br>
<span style="background:#E1EBF2">#</span><br>
<span style="background:#E1EBF2"># Kamailio (OpenSER) SIP Server v3.3 - default configuration script</span><br>
<span style="background:#E1EBF2"># - web: </span></span><a href="http://www.kamailio.org/"><span style="font-size:10.0pt;font-family:"Trebuchet MS",sans-serif;color:#5D8FBD;background:#E1EBF2">http://www.kamailio.org</span></a><span style="font-size:10.0pt;font-family:"Trebuchet MS",sans-serif;color:black"><br>
<span style="background:#E1EBF2"># - git: </span></span><a href="http://sip-router.org/"><span style="font-size:10.0pt;font-family:"Trebuchet MS",sans-serif;color:#5D8FBD;background:#E1EBF2">http://sip-router.org</span></a><span style="font-size:10.0pt;font-family:"Trebuchet MS",sans-serif;color:black"><br>
<span style="background:#E1EBF2">#</span><br>
<span style="background:#E1EBF2"># Direct your questions about this file to: <<a href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a>></span><br>
<span style="background:#E1EBF2">#</span><br>
<span style="background:#E1EBF2"># Refer to the Core CookBook at </span></span><a href="http://www.kamailio.org/dokuwiki/doku.php"><span style="font-size:10.0pt;font-family:"Trebuchet MS",sans-serif;color:#5D8FBD;background:#E1EBF2">http://www.kamailio.org/dokuwiki/doku.php</span></a><span style="font-size:10.0pt;font-family:"Trebuchet MS",sans-serif;color:black"><br>
<span style="background:#E1EBF2"># for an explanation of possible statements, functions and parameters.</span><br>
<span style="background:#E1EBF2">#</span><br>
<span style="background:#E1EBF2"># Several features can be enabled using '#!define WITH_FEATURE' directives:</span><br>
<span style="background:#E1EBF2">#</span><br>
<span style="background:#E1EBF2"># *** To run in debug mode:</span><br>
<span style="background:#E1EBF2"># - define WITH_DEBUG</span><br>
<span style="background:#E1EBF2">#</span><br>
<span style="background:#E1EBF2"># *** To enable mysql:</span><br>
<span style="background:#E1EBF2"># - define WITH_MYSQL</span><br>
<span style="background:#E1EBF2">#</span><br>
<span style="background:#E1EBF2"># *** To enable authentication execute:</span><br>
<span style="background:#E1EBF2"># - enable mysql</span><br>
<span style="background:#E1EBF2"># - define WITH_AUTH</span><br>
<span style="background:#E1EBF2"># - add users using 'kamctl'</span><br>
<span style="background:#E1EBF2">#</span><br>
<span style="background:#E1EBF2"># *** To enable IP authentication execute:</span><br>
<span style="background:#E1EBF2"># - enable mysql</span><br>
<span style="background:#E1EBF2"># - enable authentication</span><br>
<span style="background:#E1EBF2"># - define WITH_IPAUTH</span><br>
<span style="background:#E1EBF2"># - add IP addresses with group id '1' to 'address' table</span><br>
<span style="background:#E1EBF2">#</span><br>
<span style="background:#E1EBF2"># *** To enable persistent user location execute:</span><br>
<span style="background:#E1EBF2"># - enable mysql</span><br>
<span style="background:#E1EBF2"># - define WITH_USRLOCDB</span><br>
<span style="background:#E1EBF2">#</span><br>
<span style="background:#E1EBF2"># *** To enable presence server execute:</span><br>
<span style="background:#E1EBF2"># - enable mysql</span><br>
<span style="background:#E1EBF2"># - define WITH_PRESENCE</span><br>
<span style="background:#E1EBF2">#</span><br>
<span style="background:#E1EBF2"># *** To enable nat traversal execute:</span><br>
<span style="background:#E1EBF2"># - define WITH_NAT</span><br>
<span style="background:#E1EBF2"># - install RTPProxy: </span></span><a href="http://www.rtpproxy.org/"><span style="font-size:10.0pt;font-family:"Trebuchet MS",sans-serif;color:#5D8FBD;background:#E1EBF2">http://www.rtpproxy.org</span></a><span style="font-size:10.0pt;font-family:"Trebuchet MS",sans-serif;color:black"><br>
<span style="background:#E1EBF2"># - start RTPProxy:</span><br>
<span style="background:#E1EBF2"># rtpproxy -l _your_public_ip_ -s udp:localhost:7722</span><br>
<span style="background:#E1EBF2">#</span><br>
<span style="background:#E1EBF2"># *** To enable PSTN gateway routing execute:</span><br>
<span style="background:#E1EBF2"># - define WITH_PSTN</span><br>
<span style="background:#E1EBF2"># - set the value of pstn.gw_ip</span><br>
<span style="background:#E1EBF2"># - check route[PSTN] for regexp routing condition</span><br>
<span style="background:#E1EBF2">#</span><br>
<span style="background:#E1EBF2"># *** To enable database aliases lookup execute:</span><br>
<span style="background:#E1EBF2"># - enable mysql</span><br>
<span style="background:#E1EBF2"># - define WITH_ALIASDB</span><br>
<span style="background:#E1EBF2">#</span><br>
<span style="background:#E1EBF2"># *** To enable speed dial lookup execute:</span><br>
<span style="background:#E1EBF2"># - enable mysql</span><br>
<span style="background:#E1EBF2"># - define WITH_SPEEDDIAL</span><br>
<span style="background:#E1EBF2">#</span><br>
<span style="background:#E1EBF2"># *** To enable multi-domain support execute:</span><br>
<span style="background:#E1EBF2"># - enable mysql</span><br>
<span style="background:#E1EBF2"># - define WITH_MULTIDOMAIN</span><br>
<span style="background:#E1EBF2">#</span><br>
<span style="background:#E1EBF2"># *** To enable TLS support execute:</span><br>
<span style="background:#E1EBF2"># - adjust CFGDIR/tls.cfg as needed</span><br>
<span style="background:#E1EBF2"># - define WITH_TLS</span><br>
<span style="background:#E1EBF2">#</span><br>
<span style="background:#E1EBF2"># *** To enable XMLRPC support execute:</span><br>
<span style="background:#E1EBF2"># - define WITH_XMLRPC</span><br>
<span style="background:#E1EBF2"># - adjust route[XMLRPC] for access policy</span><br>
<span style="background:#E1EBF2">#</span><br>
<span style="background:#E1EBF2"># *** To enable anti-flood detection execute:</span><br>
<span style="background:#E1EBF2"># - adjust pike and htable=>ipban settings as needed (default is</span><br>
<span style="background:#E1EBF2"># block if more than 16 requests in 2 seconds and ban for 300 seconds)</span><br>
<span style="background:#E1EBF2"># - define WITH_ANTIFLOOD</span><br>
<span style="background:#E1EBF2">#</span><br>
<span style="background:#E1EBF2"># *** To block 3XX redirect replies execute:</span><br>
<span style="background:#E1EBF2"># - define WITH_BLOCK3XX</span><br>
<span style="background:#E1EBF2">#</span><br>
<span style="background:#E1EBF2"># *** To enable VoiceMail routing execute:</span><br>
<span style="background:#E1EBF2"># - define WITH_VOICEMAIL</span><br>
<span style="background:#E1EBF2"># - set the value of voicemail.srv_ip</span><br>
<span style="background:#E1EBF2"># - adjust the value of voicemail.srv_port</span><br>
<span style="background:#E1EBF2">#</span><br>
<span style="background:#E1EBF2"># *** To enhance accounting execute:</span><br>
<span style="background:#E1EBF2"># - enable mysql</span><br>
<span style="background:#E1EBF2"># - define WITH_ACCDB</span><br>
<span style="background:#E1EBF2"># - add following columns to database</span><br>
<span style="background:#E1EBF2">#!ifdef ACCDB_COMMENT</span><br>
<span style="background:#E1EBF2">ALTER TABLE acc ADD COLUMN src_user VARCHAR(64) NOT NULL DEFAULT '';</span><br>
<span style="background:#E1EBF2">ALTER TABLE acc ADD COLUMN src_domain VARCHAR(128) NOT NULL DEFAULT '';</span><br>
<span style="background:#E1EBF2">ALTER TABLE acc ADD COLUMN src_ip varchar(64) NOT NULL default '';</span><br>
<span style="background:#E1EBF2">ALTER TABLE acc ADD COLUMN dst_ouser VARCHAR(64) NOT NULL DEFAULT '';</span><br>
<span style="background:#E1EBF2">ALTER TABLE acc ADD COLUMN dst_user VARCHAR(64) NOT NULL DEFAULT '';</span><br>
<span style="background:#E1EBF2">ALTER TABLE acc ADD COLUMN dst_domain VARCHAR(128) NOT NULL DEFAULT '';</span><br>
<span style="background:#E1EBF2">ALTER TABLE missed_calls ADD COLUMN src_user VARCHAR(64) NOT NULL DEFAULT '';</span><br>
<span style="background:#E1EBF2">ALTER TABLE missed_calls ADD COLUMN src_domain VARCHAR(128) NOT NULL DEFAULT '';</span><br>
<span style="background:#E1EBF2">ALTER TABLE missed_calls ADD COLUMN src_ip varchar(64) NOT NULL default '';</span><br>
<span style="background:#E1EBF2">ALTER TABLE missed_calls ADD COLUMN dst_ouser VARCHAR(64) NOT NULL DEFAULT '';</span><br>
<span style="background:#E1EBF2">ALTER TABLE missed_calls ADD COLUMN dst_user VARCHAR(64) NOT NULL DEFAULT '';</span><br>
<span style="background:#E1EBF2">ALTER TABLE missed_calls ADD COLUMN dst_domain VARCHAR(128) NOT NULL DEFAULT '';</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2">####### Defined Values #########</span><br>
<br>
<span style="background:#E1EBF2"># *** Value defines - IDs used later in config</span><br>
<span style="background:#E1EBF2">#!ifdef WITH_MYSQL</span><br>
<span style="background:#E1EBF2"># - database URL - used to connect to database server by modules such</span><br>
<span style="background:#E1EBF2"># as: auth_db, acc, usrloc, a.s.o.</span><br>
<span style="background:#E1EBF2">#!define DBURL "mysql://kamailio:kamailiorw@localhost/kamailio"</span><br>
<span style="background:#E1EBF2">#!ifdef WITH_ASTERISK</span><br>
<span style="background:#E1EBF2">#!define DBASTURL "mysql://kamailio:kamailiorw@localhost/kamailio"</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<span style="background:#E1EBF2">#!ifdef WITH_MULTIDOMAIN</span><br>
<span style="background:#E1EBF2"># - the value for 'use_domain' parameters</span><br>
<span style="background:#E1EBF2">#!define MULTIDOMAIN 1</span><br>
<span style="background:#E1EBF2">#!else</span><br>
<span style="background:#E1EBF2">#!define MULTIDOMAIN 0</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2"># - flags</span><br>
<span style="background:#E1EBF2"># FLT_ - per transaction (message) flags</span><br>
<span style="background:#E1EBF2"># FLB_ - per branch flags</span><br>
<span style="background:#E1EBF2">#!define FLT_ACC 1</span><br>
<span style="background:#E1EBF2">#!define FLT_ACCMISSED 2</span><br>
<span style="background:#E1EBF2">#!define FLT_ACCFAILED 3</span><br>
<span style="background:#E1EBF2">#!define FLT_NATS 5</span><br>
<br>
<span style="background:#E1EBF2">#!define FLB_NATB 6</span><br>
<span style="background:#E1EBF2">#!define FLB_NATSIPPING 7</span><br>
<br>
<span style="background:#E1EBF2">####### Global Parameters #########</span><br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_DEBUG</span><br>
<span style="background:#E1EBF2">debug=4</span><br>
<span style="background:#E1EBF2">log_stderror=yes</span><br>
<span style="background:#E1EBF2">#!else</span><br>
<span style="background:#E1EBF2">debug=2</span><br>
<span style="background:#E1EBF2">log_stderror=no</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2">memdbg=5</span><br>
<span style="background:#E1EBF2">memlog=5</span><br>
<br>
<span style="background:#E1EBF2">log_facility=LOG_LOCAL7</span><br>
<br>
<span style="background:#E1EBF2">log_name="kamailio"</span><br>
<br>
<span style="background:#E1EBF2">children=4</span><br>
<br>
<span style="background:#E1EBF2">/* uncomment the next line to disable TCP (default on) */</span><br>
<span style="background:#E1EBF2">#disable_tcp=yes</span><br>
<br>
<span style="background:#E1EBF2">/* uncomment the next line to disable the auto discovery of local aliases</span><br>
<span style="background:#E1EBF2">based on reverse DNS on IPs (default on) */</span><br>
<span style="background:#E1EBF2">#auto_aliases=no</span><br>
<br>
<span style="background:#E1EBF2">/* add local domain aliases */</span><br>
<span style="background:#E1EBF2">#alias="<a href="http://sip.mydomain.com">sip.mydomain.com</a>"</span><br>
<br>
<span style="background:#E1EBF2">/* uncomment and configure the following line if you want Kamailio to</span><br>
<span style="background:#E1EBF2">bind on a specific interface/port/proto (default bind on all available) */</span><br>
<span style="background:#E1EBF2">#listen=udp:<a href="http://0.0.0.0:5060">0.0.0.0:5060</a></span><br>
<span style="background:#E1EBF2">#listen=udp: KamailioIP:5060</span><br>
<br>
<span style="background:#E1EBF2">/* port to listen to</span><br>
<span style="background:#E1EBF2">* - can be specified more than once if needed to listen on many ports */</span><br>
<span style="background:#E1EBF2">port=5060</span><br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_TLS</span><br>
<span style="background:#E1EBF2">enable_tls=yes</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2"># life time of TCP connection when there is no traffic</span><br>
<span style="background:#E1EBF2"># - a bit higher than registration expires to cope with UA behind NAT</span><br>
<span style="background:#E1EBF2">tcp_connection_lifetime=3605</span><br>
<br>
<span style="background:#E1EBF2">####### Custom Parameters #########</span><br>
<br>
<span style="background:#E1EBF2"># These parameters can be modified runtime via RPC interface</span><br>
<span style="background:#E1EBF2"># - see the documentation of 'cfg_rpc' module.</span><br>
<span style="background:#E1EBF2">#</span><br>
<span style="background:#E1EBF2"># Format: <a href="http://group.id">group.id</a> = value 'desc' description</span><br>
<span style="background:#E1EBF2"># Access: $sel(<a href="http://cfg_get.group.id">cfg_get.group.id</a>) or @<a href="http://cfg_get.group.id">cfg_get.group.id</a></span><br>
<span style="background:#E1EBF2">#</span><br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_PSTN</span><br>
<span style="background:#E1EBF2"># PSTN GW Routing</span><br>
<span style="background:#E1EBF2">#</span><br>
<span style="background:#E1EBF2"># - pstn.gw_ip: valid IP or hostname as string value, example:</span><br>
<span style="background:#E1EBF2"># pstn.gw_ip = "10.0.0.101" desc "My PSTN GW Address"</span><br>
<span style="background:#E1EBF2">#</span><br>
<span style="background:#E1EBF2"># - by default is empty to avoid misrouting</span><br>
<span style="background:#E1EBF2">pstn.gw_ip = "" desc "PSTN GW Address"</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_VOICEMAIL</span><br>
<span style="background:#E1EBF2"># VoiceMail Routing on offline, busy or no answer</span><br>
<span style="background:#E1EBF2">#</span><br>
<span style="background:#E1EBF2"># - by default Voicemail server IP is empty to avoid misrouting</span><br>
<span style="background:#E1EBF2">voicemail.srv_ip = "" desc "VoiceMail IP Address"</span><br>
<span style="background:#E1EBF2">voicemail.srv_port = "5060" desc "VoiceMail Port"</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_ASTERISK</span><br>
<span style="background:#E1EBF2">asterisk.bindip = " ASTERISKIP.164" desc "Asterisk IP Address"</span><br>
<span style="background:#E1EBF2">asterisk.bindport = "5060" desc "Asterisk Port"</span><br>
<span style="background:#E1EBF2">kamailio.bindip = " KamailioIP .95" desc "Kamailio IP Address"</span><br>
<span style="background:#E1EBF2">kamailio.bindport = "5060" desc "Kamailio Port"</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2">####### Modules Section ########</span><br>
<br>
<span style="background:#E1EBF2"># set paths to location of modules (to sources or installation folders)</span><br>
<span style="background:#E1EBF2">#!ifdef WITH_SRCPATH</span><br>
<span style="background:#E1EBF2">mpath="/usr/local/kamailio-devel/lib64/kamailio/modules/"</span><br>
<span style="background:#E1EBF2">#!else</span><br>
<span style="background:#E1EBF2">mpath="/usr/local/kamailio-devel/lib64/kamailio/modules/"</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_MYSQL</span><br>
<span style="background:#E1EBF2">loadmodule "db_mysql.so"</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2">loadmodule "kex.so"</span><br>
<span style="background:#E1EBF2">loadmodule "tm.so"</span><br>
<span style="background:#E1EBF2">loadmodule "tmx.so"</span><br>
<span style="background:#E1EBF2">loadmodule "sl.so"</span><br>
<span style="background:#E1EBF2">loadmodule "rr.so"</span><br>
<span style="background:#E1EBF2">loadmodule "pv.so"</span><br>
<span style="background:#E1EBF2">loadmodule "maxfwd.so"</span><br>
<span style="background:#E1EBF2">loadmodule "usrloc.so"</span><br>
<span style="background:#E1EBF2">loadmodule "registrar.so"</span><br>
<span style="background:#E1EBF2">loadmodule "textops.so"</span><br>
<span style="background:#E1EBF2">loadmodule "siputils.so"</span><br>
<span style="background:#E1EBF2">loadmodule "xlog.so"</span><br>
<span style="background:#E1EBF2">loadmodule "sanity.so"</span><br>
<span style="background:#E1EBF2">loadmodule "ctl.so"</span><br>
<span style="background:#E1EBF2">loadmodule "cfg_rpc.so"</span><br>
<span style="background:#E1EBF2">loadmodule "acc.so"</span><br>
<span style="background:#E1EBF2">loadmodule "sctp.so"</span><br>
<span style="background:#E1EBF2">loadmodule "dialog.so"</span><br>
<span style="background:#E1EBF2">loadmodule "siptrace.so"</span><br>
<br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_AUTH</span><br>
<span style="background:#E1EBF2">loadmodule "auth.so"</span><br>
<span style="background:#E1EBF2">loadmodule "auth_db.so"</span><br>
<span style="background:#E1EBF2">#!ifdef WITH_IPAUTH</span><br>
<span style="background:#E1EBF2">loadmodule "permissions.so"</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_ALIASDB</span><br>
<span style="background:#E1EBF2">loadmodule "alias_db.so"</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_SPEEDDIAL</span><br>
<span style="background:#E1EBF2">loadmodule "speeddial.so"</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_MULTIDOMAIN</span><br>
<span style="background:#E1EBF2">loadmodule "domain.so"</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_PRESENCE</span><br>
<span style="background:#E1EBF2">loadmodule "presence.so"</span><br>
<span style="background:#E1EBF2">loadmodule "presence_xml.so"</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_NAT</span><br>
<span style="background:#E1EBF2">loadmodule "nathelper.so"</span><br>
<span style="background:#E1EBF2">loadmodule "rtpproxy.so"</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_TLS</span><br>
<span style="background:#E1EBF2">loadmodule "tls.so"</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_ANTIFLOOD</span><br>
<span style="background:#E1EBF2">loadmodule "htable.so"</span><br>
<span style="background:#E1EBF2">loadmodule "pike.so"</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_XMLRPC</span><br>
<span style="background:#E1EBF2">loadmodule "xmlrpc.so"</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_DEBUG</span><br>
<span style="background:#E1EBF2">loadmodule "debugger.so"</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_ASTERISK</span><br>
<br>
<span style="background:#E1EBF2">loadmodule "uac.so"</span><br>
<span style="background:#E1EBF2">loadmodule "dispatcher.so"</span><br>
<span style="background:#E1EBF2">loadmodule "jsonrpcs.so"</span><br>
<span style="background:#E1EBF2">loadmodule "htable.so"</span><br>
<br>
<span style="background:#E1EBF2"># ---------------------- mod dispatcher params ------------------------------</span><br>
<br>
<span style="background:#E1EBF2">modparam("dispatcher", "db_url", DBURL)</span><br>
<span style="background:#E1EBF2">modparam("dispatcher", "table_name", "dispatcher")</span><br>
<span style="background:#E1EBF2">modparam("dispatcher", "ds_ping_interval", 15)</span><br>
<span style="background:#E1EBF2">modparam("dispatcher", "ds_ping_from", "<a href="sip:dispathcer@%20KamailioIP%20">sip:dispathcer@ KamailioIP
</a>")</span><br>
<span style="background:#E1EBF2">modparam("dispatcher", "force_dst", 1)</span><br>
<span style="background:#E1EBF2">modparam("dispatcher", "ds_ping_method", "INFO")</span><br>
<span style="background:#E1EBF2">#modparam("dispatcher", "ds_probing_mode", 1)</span><br>
<span style="background:#E1EBF2">modparam("dispatcher", "ds_probing_threshold", 1)</span><br>
<span style="background:#E1EBF2">#modparam("dispatcher", "ds_ping_reply_codes", "class=2;code=403;code=404;code=484;code=488;code=481;class=3")</span><br>
<span style="background:#E1EBF2">modparam("dispatcher", "ds_ping_reply_codes", "class=2;class=3;class=4")</span><br>
<span style="background:#E1EBF2">#modparam("dispatcher", "priority_col", "dstpriority")</span><br>
<span style="background:#E1EBF2">#modparam("dispatcher", "dstid_avp", "$avp(dsdstid)")</span><br>
<span style="background:#E1EBF2"># do failover</span><br>
<span style="background:#E1EBF2">modparam("dispatcher", "flags", 2)</span><br>
<span style="background:#E1EBF2">#modparam("dispatcher", "dst_avp", "$avp(AVP_DST)")</span><br>
<span style="background:#E1EBF2">#modparam("dispatcher", "grp_avp", "$avp(AVP_GRP)")</span><br>
<span style="background:#E1EBF2">#modparam("dispatcher", "cnt_avp", "$avp(AVP_CNT)")</span><br>
<br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2"># ----------------- setting module-specific parameters ---------------</span><br>
<span style="background:#E1EBF2">modparam("siptrace", "db_url", DBURL)</span><br>
<span style="background:#E1EBF2">modparam("siptrace", "trace_flag", 22)</span><br>
<span style="background:#E1EBF2">modparam("siptrace", "trace_on", 1)</span><br>
<span style="background:#E1EBF2"># ----- jsonrpcs params -----</span><br>
<span style="background:#E1EBF2">modparam("jsonrpcs", "pretty_format", 1)</span><br>
<span style="background:#E1EBF2">/* set the path to RPC fifo control file */</span><br>
<span style="background:#E1EBF2"># modparam("jsonrpcs", "fifo_name", "/run/kamailio/kamailio_rpc.fifo")</span><br>
<span style="background:#E1EBF2">/* set the path to RPC unix socket control file */</span><br>
<span style="background:#E1EBF2"># modparam("jsonrpcs", "dgram_socket", "/run/kamailio/kamailio_rpc.sock")</span><br>
<span style="background:#E1EBF2">#!ifdef WITH_JSONRPC</span><br>
<span style="background:#E1EBF2">modparam("jsonrpcs", "transport", 7)</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2"># ---------------------- mod uac params ------------------------------</span><br>
<br>
<span style="background:#E1EBF2">modparam("uac", "reg_contact_addr", "ASTERISKIP:5060")</span><br>
<span style="background:#E1EBF2">modparam("uac", "reg_db_url", "mysql://kamailio:kamailiorw@localhost/kamailio")</span><br>
<span style="background:#E1EBF2">modparam("uac", "reg_db_table", "uacreg")</span><br>
<span style="background:#E1EBF2">modparam("uac", "reg_timer_interval", 60)</span><br>
<span style="background:#E1EBF2">modparam("uac","restore_mode","auto")</span><br>
<span style="background:#E1EBF2">modparam("uac", "restore_dlg", 1)</span><br>
<span style="background:#E1EBF2">modparam("uac","auth_realm_avp","$avp(s:auth_realm_avp)")</span><br>
<span style="background:#E1EBF2">modparam("uac","auth_username_avp","$avp(s:auth_username_avp)")</span><br>
<span style="background:#E1EBF2">modparam("uac","auth_password_avp","$avp(s:auth_password_avp)")</span><br>
<br>
<br>
<br>
<span style="background:#E1EBF2"># ----- mi_fifo params -----</span><br>
<span style="background:#E1EBF2">#modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")</span><br>
<br>
<br>
<span style="background:#E1EBF2"># ----- tm params -----</span><br>
<span style="background:#E1EBF2"># auto-discard branches from previous serial forking leg</span><br>
<span style="background:#E1EBF2">modparam("tm", "failure_reply_mode", 3)</span><br>
<span style="background:#E1EBF2"># default retransmission timeout: 30sec</span><br>
<span style="background:#E1EBF2">modparam("tm", "fr_timer", 30000)</span><br>
<span style="background:#E1EBF2"># default invite retransmission timeout after 1xx: 120sec</span><br>
<span style="background:#E1EBF2">modparam("tm", "fr_inv_timer", 120000)</span><br>
<span style="background:#E1EBF2">modparam("tm", "ruri_matching", 0)</span><br>
<br>
<span style="background:#E1EBF2"># ----- rr params -----</span><br>
<span style="background:#E1EBF2"># add value to ;lr param to cope with most of the UAs</span><br>
<span style="background:#E1EBF2">modparam("rr", "enable_full_lr", 1)</span><br>
<span style="background:#E1EBF2"># do not append from tag to the RR (no need for this script)</span><br>
<span style="background:#E1EBF2">#!ifdef WITH_ASTERISK</span><br>
<span style="background:#E1EBF2">modparam("rr", "append_fromtag", 1)</span><br>
<span style="background:#E1EBF2">#!else</span><br>
<span style="background:#E1EBF2">modparam("rr", "append_fromtag", 0)</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2"># ----- registrar params -----</span><br>
<span style="background:#E1EBF2">modparam("registrar", "method_filtering", 1)</span><br>
<span style="background:#E1EBF2">/* uncomment the next line to disable parallel forking via location */</span><br>
<span style="background:#E1EBF2"># modparam("registrar", "append_branches", 0)</span><br>
<span style="background:#E1EBF2">/* uncomment the next line not to allow more than 10 contacts per AOR */</span><br>
<span style="background:#E1EBF2">#modparam("registrar", "max_contacts", 10)</span><br>
<span style="background:#E1EBF2"># max value for expires of registrations</span><br>
<span style="background:#E1EBF2">modparam("registrar", "max_expires", 3600)</span><br>
<span style="background:#E1EBF2"># set it to 1 to enable GRUU</span><br>
<span style="background:#E1EBF2">modparam("registrar", "gruu_enabled", 0)</span><br>
<br>
<br>
<span style="background:#E1EBF2"># ----- acc params -----</span><br>
<span style="background:#E1EBF2">/* what special events should be accounted ? */</span><br>
<span style="background:#E1EBF2">modparam("acc", "early_media", 0)</span><br>
<span style="background:#E1EBF2">modparam("acc", "report_ack", 0)</span><br>
<span style="background:#E1EBF2">modparam("acc", "report_cancels", 0)</span><br>
<span style="background:#E1EBF2">/* by default ww do not adjust the direct of the sequential requests.</span><br>
<span style="background:#E1EBF2">if you enable this parameter, be sure the enable "append_fromtag"</span><br>
<span style="background:#E1EBF2">in "rr" module */</span><br>
<span style="background:#E1EBF2">modparam("acc", "detect_direction", 0)</span><br>
<span style="background:#E1EBF2">/* account triggers (flags) */</span><br>
<span style="background:#E1EBF2">modparam("acc", "log_flag", FLT_ACC)</span><br>
<span style="background:#E1EBF2">modparam("acc", "log_missed_flag", FLT_ACCMISSED)</span><br>
<span style="background:#E1EBF2">modparam("acc", "log_extra",</span><br>
<span style="background:#E1EBF2">"src_user=$fU;src_domain=$fd;src_ip=$si;"</span><br>
<span style="background:#E1EBF2">"dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")</span><br>
<span style="background:#E1EBF2">modparam("acc", "failed_transaction_flag", FLT_ACCFAILED)</span><br>
<span style="background:#E1EBF2">/* enhanced DB accounting */</span><br>
<span style="background:#E1EBF2">#!ifdef WITH_ACCDB</span><br>
<span style="background:#E1EBF2">modparam("acc", "db_flag", FLT_ACC)</span><br>
<span style="background:#E1EBF2">modparam("acc", "db_missed_flag", FLT_ACCMISSED)</span><br>
<span style="background:#E1EBF2">modparam("acc", "db_url", DBURL)</span><br>
<span style="background:#E1EBF2">modparam("acc", "db_extra",</span><br>
<span style="background:#E1EBF2">"src_user=$fU;src_domain=$fd;src_ip=$si;"</span><br>
<span style="background:#E1EBF2">"dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<br>
<span style="background:#E1EBF2"># ----- usrloc params -----</span><br>
<span style="background:#E1EBF2">/* enable DB persistency for location entries */</span><br>
<span style="background:#E1EBF2">#!ifdef WITH_USRLOCDB</span><br>
<span style="background:#E1EBF2">modparam("usrloc", "db_url", DBURL)</span><br>
<span style="background:#E1EBF2">modparam("usrloc", "db_mode", 2)</span><br>
<span style="background:#E1EBF2">modparam("usrloc", "use_domain", MULTIDOMAIN)</span><br>
<span style="background:#E1EBF2">modparam("usrloc", "matching_mode", 1)</span><br>
<span style="background:#E1EBF2">modparam("usrloc", "db_insert_update", 1)</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<br>
<span style="background:#E1EBF2"># ----- auth_db params -----</span><br>
<span style="background:#E1EBF2">#!ifdef WITH_AUTH</span><br>
<br>
<span style="background:#E1EBF2">modparam("auth_db", "db_url", DBURL)</span><br>
<span style="background:#E1EBF2">modparam("auth_db", "calculate_ha1", yes)</span><br>
<span style="background:#E1EBF2">modparam("auth_db", "load_credentials", "")</span><br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_ASTERISK</span><br>
<span style="background:#E1EBF2">modparam("auth_db", "user_column", "username")</span><br>
<span style="background:#E1EBF2">modparam("auth_db", "password_column", "secret")</span><br>
<span style="background:#E1EBF2">modparam("auth_db", "db_url", DBASTURL)</span><br>
<span style="background:#E1EBF2">modparam("auth_db", "version_table", 0)</span><br>
<span style="background:#E1EBF2">#!else</span><br>
<span style="background:#E1EBF2">modparam("auth_db", "db_url", DBURL)</span><br>
<span style="background:#E1EBF2">modparam("auth_db", "password_column", "password")</span><br>
<span style="background:#E1EBF2">modparam("auth_db", "use_domain", MULTIDOMAIN)</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2"># ----- permissions params -----</span><br>
<span style="background:#E1EBF2">#!ifdef WITH_IPAUTH</span><br>
<span style="background:#E1EBF2">modparam("permissions", "db_url", DBURL)</span><br>
<span style="background:#E1EBF2">modparam("permissions", "db_mode", 1)</span><br>
<span style="background:#E1EBF2">modparam("permissions", "trusted_table", "trusted")</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<br>
<span style="background:#E1EBF2"># ----- alias_db params -----</span><br>
<span style="background:#E1EBF2">#!ifdef WITH_ALIASDB</span><br>
<span style="background:#E1EBF2">modparam("alias_db", "db_url", DBURL)</span><br>
<span style="background:#E1EBF2">modparam("alias_db", "use_domain", MULTIDOMAIN)</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<br>
<span style="background:#E1EBF2"># ----- speedial params -----</span><br>
<span style="background:#E1EBF2">#!ifdef WITH_SPEEDDIAL</span><br>
<span style="background:#E1EBF2">modparam("speeddial", "db_url", DBURL)</span><br>
<span style="background:#E1EBF2">modparam("speeddial", "use_domain", MULTIDOMAIN)</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<br>
<span style="background:#E1EBF2"># ----- domain params -----</span><br>
<span style="background:#E1EBF2">#!ifdef WITH_MULTIDOMAIN</span><br>
<span style="background:#E1EBF2">modparam("domain", "db_url", DBURL)</span><br>
<span style="background:#E1EBF2"># register callback to match myself condition with domains list</span><br>
<span style="background:#E1EBF2">modparam("domain", "register_myself", 1)</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_PRESENCE</span><br>
<span style="background:#E1EBF2"># ----- presence params -----</span><br>
<span style="background:#E1EBF2">modparam("presence", "db_url", DBURL)</span><br>
<br>
<span style="background:#E1EBF2"># ----- presence_xml params -----</span><br>
<span style="background:#E1EBF2">modparam("presence_xml", "db_url", DBURL)</span><br>
<span style="background:#E1EBF2">modparam("presence_xml", "force_active", 1)</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_NAT</span><br>
<span style="background:#E1EBF2"># ----- rtpproxy params -----</span><br>
<span style="background:#E1EBF2">modparam("rtpproxy", "rtpproxy_sock", "udp:<a href="http://127.0.0.1:7722">127.0.0.1:7722</a>")</span><br>
<br>
<span style="background:#E1EBF2"># ----- nathelper params -----</span><br>
<span style="background:#E1EBF2">modparam("nathelper", "natping_interval", 30)</span><br>
<span style="background:#E1EBF2">modparam("nathelper", "ping_nated_only", 1)</span><br>
<span style="background:#E1EBF2">modparam("nathelper", "sipping_bflag", FLB_NATSIPPING)</span><br>
<span style="background:#E1EBF2">modparam("nathelper", "sipping_from", "<a href="mailto:sip%3Apinger@kamailio.org">sip:pinger@kamailio.org</a>")</span><br>
<br>
<span style="background:#E1EBF2"># params needed for NAT traversal in other modules</span><br>
<span style="background:#E1EBF2">modparam("nathelper|registrar", "received_avp", "$avp(RECEIVED)")</span><br>
<span style="background:#E1EBF2">modparam("usrloc", "nat_bflag", FLB_NATB)</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_TLS</span><br>
<span style="background:#E1EBF2"># ----- tls params -----</span><br>
<span style="background:#E1EBF2">modparam("tls", "config", "/usr/local/etc/kamailio/tls.cfg")</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_ANTIFLOOD</span><br>
<span style="background:#E1EBF2"># ----- pike params -----</span><br>
<span style="background:#E1EBF2">modparam("pike", "sampling_time_unit", 2)</span><br>
<span style="background:#E1EBF2">modparam("pike", "reqs_density_per_unit", 16)</span><br>
<span style="background:#E1EBF2">modparam("pike", "remove_latency", 4)</span><br>
<br>
<span style="background:#E1EBF2"># ----- htable params -----</span><br>
<span style="background:#E1EBF2"># ip ban htable with autoexpire after 5 minutes</span><br>
<span style="background:#E1EBF2">#modparam("htable", "htable", "ipban=>size=8;autoexpire=300;")</span><br>
<span style="background:#E1EBF2">modparam("htable", "htable", "stats=>size=6;")</span><br>
<br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_XMLRPC</span><br>
<span style="background:#E1EBF2"># ----- xmlrpc params -----</span><br>
<span style="background:#E1EBF2">modparam("xmlrpc", "route", "XMLRPC");</span><br>
<span style="background:#E1EBF2">modparam("xmlrpc", "url_match", "^/RPC")</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_DEBUG</span><br>
<span style="background:#E1EBF2"># ----- debugger params -----</span><br>
<span style="background:#E1EBF2">#modparam("debugger", "cfgtrace", 1)</span><br>
<span style="background:#E1EBF2">#modparam("debugger", "breakpoint", 1)</span><br>
<span style="background:#E1EBF2">modparam("debugger", "log_level_name", "exec")</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2">####### Routing Logic ########</span><br>
<br>
<br>
<span style="background:#E1EBF2"># Main SIP request routing logic</span><br>
<span style="background:#E1EBF2"># - processing of any incoming SIP request starts with this route</span><br>
<span style="background:#E1EBF2"># - note: this is the same as route { ... }</span><br>
<br>
<br>
<span style="background:#E1EBF2">request_route {</span><br>
<br>
<span style="background:#E1EBF2">route(DISPATCH);</span><br>
<br>
<span style="background:#E1EBF2"># per request initial checks</span><br>
<span style="background:#E1EBF2">route(REQINIT);</span><br>
<br>
<span style="background:#E1EBF2"># NAT detection</span><br>
<span style="background:#E1EBF2">route(NATDETECT);</span><br>
<br>
<span style="background:#E1EBF2"># handle requests within SIP dialogs</span><br>
<span style="background:#E1EBF2">route(WITHINDLG);</span><br>
<br>
<span style="background:#E1EBF2">### only initial requests (no To tag)</span><br>
<br>
<span style="background:#E1EBF2">if(is_method("OPTIONS"))</span><br>
<span style="background:#E1EBF2">{</span><br>
<span style="background:#E1EBF2">sl_send_reply("200","Keepalive");</span><br>
<br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">if(is_method("NOTIFY"))</span><br>
<span style="background:#E1EBF2">{</span><br>
<span style="background:#E1EBF2">sl_send_reply("200","OK");</span><br>
<br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<span style="background:#E1EBF2"># CANCEL processing</span><br>
<span style="background:#E1EBF2">if (is_method("CANCEL"))</span><br>
<span style="background:#E1EBF2">{</span><br>
<span style="background:#E1EBF2">if (t_check_trans())</span><br>
<span style="background:#E1EBF2">t_relay();</span><br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<span style="background:#E1EBF2">t_check_trans();</span><br>
<br>
<span style="background:#E1EBF2"># authentication</span><br>
<br>
<span style="background:#E1EBF2">route(AUTH);</span><br>
<br>
<span style="background:#E1EBF2"># record routing for dialog forming requests (in case they are routed)</span><br>
<span style="background:#E1EBF2"># - remove preloaded route headers</span><br>
<span style="background:#E1EBF2">remove_hf("Route");</span><br>
<br>
<span style="background:#E1EBF2">if (is_method("INVITE|SUBSCRIBE"))</span><br>
<span style="background:#E1EBF2">record_route();</span><br>
<br>
<span style="background:#E1EBF2"># account only INVITEs</span><br>
<span style="background:#E1EBF2">if (is_method("INVITE"))</span><br>
<span style="background:#E1EBF2">{</span><br>
<br>
<span style="background:#E1EBF2">setflag(FLT_ACC); # do accounting</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<br>
<span style="background:#E1EBF2"># dispatch requests to foreign domains</span><br>
<span style="background:#E1EBF2">route(SIPOUT);</span><br>
<br>
<span style="background:#E1EBF2">### requests for my local domains</span><br>
<br>
<span style="background:#E1EBF2"># handle presence related requests</span><br>
<span style="background:#E1EBF2">route(PRESENCE);</span><br>
<br>
<span style="background:#E1EBF2"># handle registrations</span><br>
<span style="background:#E1EBF2">route(REGISTRAR);</span><br>
<br>
<span style="background:#E1EBF2">if ($rU==$null)</span><br>
<span style="background:#E1EBF2">{</span><br>
<span style="background:#E1EBF2"># request with no Username in RURI</span><br>
<span style="background:#E1EBF2">sl_send_reply("484","Address Incomplete");</span><br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<span style="background:#E1EBF2"># dispatch destinations to PSTN</span><br>
<span style="background:#E1EBF2">route(PSTN);</span><br>
<br>
<span style="background:#E1EBF2"># user location service</span><br>
<span style="background:#E1EBF2">route(LOCATION);</span><br>
<br>
<span style="background:#E1EBF2">route(RELAY);</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<br>
<span style="background:#E1EBF2">route[RELAY] {</span><br>
<br>
<span style="background:#E1EBF2"># enable additional event routes for forwarded requests</span><br>
<span style="background:#E1EBF2"># - serial forking, RTP relaying handling, a.s.o.</span><br>
<span style="background:#E1EBF2">if (is_method("INVITE|SUBSCRIBE")) {</span><br>
<span style="background:#E1EBF2">t_on_branch("MANAGE_BRANCH");</span><br>
<span style="background:#E1EBF2">t_on_reply("MANAGE_REPLY");</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">if (is_method("INVITE")) {</span><br>
<span style="background:#E1EBF2">t_on_failure("MANAGE_FAILURE");</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<span style="background:#E1EBF2">if (!t_relay()) {</span><br>
<span style="background:#E1EBF2">sl_reply_error();</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<span style="background:#E1EBF2"># Per SIP request initial checks</span><br>
<span style="background:#E1EBF2">route[REQINIT] {</span><br>
<span style="background:#E1EBF2">#!ifdef WITH_ANTIFLOOD</span><br>
<span style="background:#E1EBF2"># flood dection from same IP and traffic ban for a while</span><br>
<span style="background:#E1EBF2"># be sure you exclude checking trusted peers, such as pstn gateways</span><br>
<span style="background:#E1EBF2"># - local host excluded (e.g., loop to self)</span><br>
<span style="background:#E1EBF2">if(src_ip!=myself)</span><br>
<span style="background:#E1EBF2">{</span><br>
<span style="background:#E1EBF2">if($sht(ipban=>$si)!=$null)</span><br>
<span style="background:#E1EBF2">{</span><br>
<span style="background:#E1EBF2"># ip is already blocked</span><br>
<span style="background:#E1EBF2">xdbg("request from blocked IP - $rm from $fu (IP:$si:$sp)\n");</span><br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">if (!pike_check_req())</span><br>
<span style="background:#E1EBF2">{</span><br>
<span style="background:#E1EBF2">xlog("L_ALERT","ALERT: pike blocking $rm from $fu (IP:$si:$sp)\n");</span><br>
<span style="background:#E1EBF2">$sht(ipban=>$si) = 1;</span><br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<br>
<br>
<span style="background:#E1EBF2">if (!mf_process_maxfwd_header("10")) {</span><br>
<span style="background:#E1EBF2">sl_send_reply("483","Too Many Hops");</span><br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<span style="background:#E1EBF2">if(!sanity_check("1511", "7"))</span><br>
<span style="background:#E1EBF2">{</span><br>
<span style="background:#E1EBF2">xlog("Malformed SIP message from $si:$sp\n");</span><br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<span style="background:#E1EBF2"># Handle requests within SIP dialogs</span><br>
<span style="background:#E1EBF2">route[WITHINDLG] {</span><br>
<span style="background:#E1EBF2">if (has_totag()) {</span><br>
<span style="background:#E1EBF2"># sequential request withing a dialog should</span><br>
<span style="background:#E1EBF2"># take the path determined by record-routing</span><br>
<span style="background:#E1EBF2">if (loose_route()) {</span><br>
<span style="background:#E1EBF2">if (is_method("BYE")) {</span><br>
<span style="background:#E1EBF2">setflag(FLT_ACC); # do accounting ...</span><br>
<span style="background:#E1EBF2">setflag(FLT_ACCFAILED); # ... even if the transaction fails</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">if ( is_method("ACK") ) {</span><br>
<span style="background:#E1EBF2"># ACK is forwarded statelessy</span><br>
<span style="background:#E1EBF2">route(NATMANAGE);</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">route(RELAY);</span><br>
<span style="background:#E1EBF2">} else {</span><br>
<span style="background:#E1EBF2">if (is_method("SUBSCRIBE") && uri == myself) {</span><br>
<span style="background:#E1EBF2"># in-dialog subscribe requests</span><br>
<span style="background:#E1EBF2">route(PRESENCE);</span><br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">if ( is_method("ACK") ) {</span><br>
<span style="background:#E1EBF2">if ( t_check_trans() ) {</span><br>
<span style="background:#E1EBF2"># no loose-route, but stateful ACK;</span><br>
<span style="background:#E1EBF2"># must be an ACK after a 487</span><br>
<span style="background:#E1EBF2"># or e.g. 404 from upstream server</span><br>
<span style="background:#E1EBF2">t_relay();</span><br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">} else {</span><br>
<span style="background:#E1EBF2"># ACK without matching transaction ... ignore and discard</span><br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">sl_send_reply("404","Not here");</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<span style="background:#E1EBF2"># Handle SIP registrations</span><br>
<span style="background:#E1EBF2">route[REGISTRAR] {</span><br>
<span style="background:#E1EBF2">if (is_method("REGISTER"))</span><br>
<span style="background:#E1EBF2">{</span><br>
<span style="background:#E1EBF2">if(isflagset(FLT_NATS))</span><br>
<span style="background:#E1EBF2">{</span><br>
<span style="background:#E1EBF2">setbflag(FLB_NATB);</span><br>
<span style="background:#E1EBF2"># uncomment next line to do SIP NAT pinging</span><br>
<span style="background:#E1EBF2">## setbflag(FLB_NATSIPPING);</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">if (!save("location"))</span><br>
<span style="background:#E1EBF2">sl_reply_error();</span><br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_ASTERISK</span><br>
<span style="background:#E1EBF2">route(REGFWD);</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<span style="background:#E1EBF2"># USER location service</span><br>
<span style="background:#E1EBF2">route[LOCATION] {</span><br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_SPEEDIAL</span><br>
<span style="background:#E1EBF2"># search for short dialing - 2-digit extension</span><br>
<span style="background:#E1EBF2">if($rU=~"^[0-9][0-9]$")</span><br>
<span style="background:#E1EBF2">if(sd_lookup("speed_dial"))</span><br>
<span style="background:#E1EBF2">route(SIPOUT);</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_ALIASDB</span><br>
<span style="background:#E1EBF2"># search in DB-based aliases</span><br>
<span style="background:#E1EBF2">if(alias_db_lookup("dbaliases"))</span><br>
<span style="background:#E1EBF2">route(SIPOUT);</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_ASTERISK</span><br>
<span style="background:#E1EBF2">if(is_method("INVITE") && (!route(FROMASTERISK))) {</span><br>
<span style="background:#E1EBF2"># if new call from out there - send to Asterisk</span><br>
<span style="background:#E1EBF2"># - non-INVITE request are routed directly by Kamailio</span><br>
<span style="background:#E1EBF2"># - traffic from Asterisk is routed also directy by Kamailio</span><br>
<span style="background:#E1EBF2">append_hf("FromIp: $src_ip\r\n", "Call-ID");</span><br>
<span style="background:#E1EBF2">route(TOASTERISK);</span><br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2">$avp(oexten) = $rU;</span><br>
<span style="background:#E1EBF2">if (!lookup("location")) {</span><br>
<span style="background:#E1EBF2">$var(rc) = $rc;</span><br>
<span style="background:#E1EBF2">route(TOVOICEMAIL);</span><br>
<span style="background:#E1EBF2">t_newtran();</span><br>
<span style="background:#E1EBF2">switch ($var(rc)) {</span><br>
<span style="background:#E1EBF2">case -1:</span><br>
<span style="background:#E1EBF2">case -3:</span><br>
<span style="background:#E1EBF2">send_reply("404", "Not Found");</span><br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">case -2:</span><br>
<span style="background:#E1EBF2">send_reply("405", "Method Not Allowed");</span><br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<span style="background:#E1EBF2"># when routing via usrloc, log the missed calls also</span><br>
<span style="background:#E1EBF2">if (is_method("INVITE"))</span><br>
<span style="background:#E1EBF2">{</span><br>
<span style="background:#E1EBF2">setflag(FLT_ACCMISSED);</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<span style="background:#E1EBF2"># Presence server route</span><br>
<span style="background:#E1EBF2">route[PRESENCE] {</span><br>
<span style="background:#E1EBF2">if(!is_method("PUBLISH|SUBSCRIBE"))</span><br>
<span style="background:#E1EBF2">return;</span><br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_PRESENCE</span><br>
<span style="background:#E1EBF2">if (!t_newtran())</span><br>
<span style="background:#E1EBF2">{</span><br>
<span style="background:#E1EBF2">sl_reply_error();</span><br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">};</span><br>
<br>
<span style="background:#E1EBF2">if(is_method("PUBLISH"))</span><br>
<span style="background:#E1EBF2">{</span><br>
<span style="background:#E1EBF2">handle_publish();</span><br>
<span style="background:#E1EBF2">t_release();</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">else</span><br>
<span style="background:#E1EBF2">if( is_method("SUBSCRIBE"))</span><br>
<span style="background:#E1EBF2">{</span><br>
<span style="background:#E1EBF2">handle_subscribe();</span><br>
<span style="background:#E1EBF2">t_release();</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2"># if presence enabled, this part will not be executed</span><br>
<span style="background:#E1EBF2">if (is_method("PUBLISH") || $rU==$null)</span><br>
<span style="background:#E1EBF2">{</span><br>
<span style="background:#E1EBF2">sl_send_reply("404", "Not here");</span><br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">return;</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<span style="background:#E1EBF2"># Authentication route</span><br>
<span style="background:#E1EBF2">route[AUTH] {</span><br>
<span style="background:#E1EBF2">#!ifdef WITH_AUTH</span><br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_ASTERISK</span><br>
<span style="background:#E1EBF2"># do not auth traffic from Asterisk - trusted!</span><br>
<span style="background:#E1EBF2">if(route(FROMASTERISK))</span><br>
<span style="background:#E1EBF2">return;</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_IPAUTH</span><br>
<br>
<span style="background:#E1EBF2">if((!is_method("REGISTER")) && allow_source_address())</span><br>
<span style="background:#E1EBF2">{</span><br>
<br>
<span style="background:#E1EBF2"># source IP allowed</span><br>
<span style="background:#E1EBF2">return;</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">if (is_method("REGISTER") || from_uri==myself){</span><br>
<span style="background:#E1EBF2">if (!allow_trusted()) {</span><br>
<span style="background:#E1EBF2">xlog('wokred here for ipauth check');</span><br>
<span style="background:#E1EBF2">sl_send_reply("403", "Forbidden");</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<br>
<br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2">if (is_method("REGISTER") || from_uri==myself)</span><br>
<span style="background:#E1EBF2">{</span><br>
<span style="background:#E1EBF2"># authenticate requests</span><br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_ASTERISK</span><br>
<br>
<span style="background:#E1EBF2">if (!auth_check("$fd", "sip_users", "1")) {</span><br>
<span style="background:#E1EBF2">#!else</span><br>
<span style="background:#E1EBF2">if (!auth_check("$fd", "subscriber", "1")) {</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<span style="background:#E1EBF2">auth_challenge("$fd", "0");</span><br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2"># user authenticated - remove auth header</span><br>
<span style="background:#E1EBF2">if(!is_method("REGISTER|PUBLISH"))</span><br>
<span style="background:#E1EBF2">consume_credentials();</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2"># if caller is not local subscriber, then check if it calls</span><br>
<span style="background:#E1EBF2"># a local destination, otherwise deny, not an open relay here</span><br>
<span style="background:#E1EBF2">if (from_uri!=myself && uri!=myself)</span><br>
<span style="background:#E1EBF2">{</span><br>
<span style="background:#E1EBF2">sl_send_reply("403","Not relaying");</span><br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<span style="background:#E1EBF2">#!endif</span><br>
<span style="background:#E1EBF2">return;</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<span style="background:#E1EBF2"># Caller NAT detection route</span><br>
<span style="background:#E1EBF2">route[NATDETECT] {</span><br>
<span style="background:#E1EBF2">#!ifdef WITH_NAT</span><br>
<span style="background:#E1EBF2">force_rport();</span><br>
<span style="background:#E1EBF2">if (nat_uac_test("19")) {</span><br>
<span style="background:#E1EBF2">if (is_method("REGISTER")) {</span><br>
<span style="background:#E1EBF2">fix_nated_register();</span><br>
<span style="background:#E1EBF2">} else {</span><br>
<span style="background:#E1EBF2">fix_nated_contact();</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">setflag(FLT_NATS);</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<span style="background:#E1EBF2">return;</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<span style="background:#E1EBF2"># RTPProxy control</span><br>
<span style="background:#E1EBF2">route[NATMANAGE] {</span><br>
<span style="background:#E1EBF2">#!ifdef WITH_NAT</span><br>
<span style="background:#E1EBF2">if (is_request()) {</span><br>
<span style="background:#E1EBF2">if(has_totag()) {</span><br>
<span style="background:#E1EBF2">if(check_route_param("nat=yes")) {</span><br>
<span style="background:#E1EBF2">setbflag(FLB_NATB);</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">if (!(isflagset(FLT_NATS) || isbflagset(FLB_NATB)))</span><br>
<span style="background:#E1EBF2">return;</span><br>
<br>
<span style="background:#E1EBF2">rtpproxy_manage();</span><br>
<br>
<span style="background:#E1EBF2">if (is_request()) {</span><br>
<span style="background:#E1EBF2">if (!has_totag()) {</span><br>
<span style="background:#E1EBF2">add_rr_param(";nat=yes");</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">if (is_reply()) {</span><br>
<span style="background:#E1EBF2">if(isbflagset(FLB_NATB)) {</span><br>
<span style="background:#E1EBF2">fix_nated_contact();</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<span style="background:#E1EBF2">return;</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<span style="background:#E1EBF2"># Routing to foreign domains</span><br>
<span style="background:#E1EBF2">route[SIPOUT] {</span><br>
<span style="background:#E1EBF2">if (!uri==myself)</span><br>
<span style="background:#E1EBF2">{</span><br>
<span style="background:#E1EBF2">append_hf("P-hint: outbound\r\n");</span><br>
<span style="background:#E1EBF2">route(RELAY);</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<span style="background:#E1EBF2"># PSTN GW routing</span><br>
<span style="background:#E1EBF2">route[PSTN] {</span><br>
<span style="background:#E1EBF2">#!ifdef WITH_PSTN</span><br>
<span style="background:#E1EBF2"># check if PSTN GW IP is defined</span><br>
<span style="background:#E1EBF2">if (strempty($sel(cfg_get.pstn.gw_ip))) {</span><br>
<span style="background:#E1EBF2">xlog("SCRIPT: PSTN rotuing enabled but pstn.gw_ip not defined\n");</span><br>
<span style="background:#E1EBF2">return;</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<span style="background:#E1EBF2"># route to PSTN dialed numbers starting with '+' or '00'</span><br>
<span style="background:#E1EBF2"># (international format)</span><br>
<span style="background:#E1EBF2"># - update the condition to match your dialing rules for PSTN routing</span><br>
<span style="background:#E1EBF2">if(!($rU=~"^(\+|00)[1-9][0-9]{3,20}$"))</span><br>
<span style="background:#E1EBF2">return;</span><br>
<br>
<span style="background:#E1EBF2"># only local users allowed to call</span><br>
<span style="background:#E1EBF2">if(from_uri!=myself) {</span><br>
<span style="background:#E1EBF2">sl_send_reply("403", "Not Allowed");</span><br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<span style="background:#E1EBF2">$ru = "sip:" + $rU + "@" + $sel(cfg_get.pstn.gw_ip);</span><br>
<br>
<span style="background:#E1EBF2">route(RELAY);</span><br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2">return;</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<span style="background:#E1EBF2"># XMLRPC routing</span><br>
<span style="background:#E1EBF2">#!ifdef WITH_XMLRPC</span><br>
<span style="background:#E1EBF2">route[XMLRPC] {</span><br>
<span style="background:#E1EBF2"># allow XMLRPC from localhost</span><br>
<span style="background:#E1EBF2">if ((method=="POST" || method=="GET")</span><br>
<span style="background:#E1EBF2">&& (src_ip==127.0.0.1)) {</span><br>
<span style="background:#E1EBF2"># close connection only for xmlrpclib user agents (there is a bug in</span><br>
<span style="background:#E1EBF2"># xmlrpclib: it waits for EOF before interpreting the response).</span><br>
<span style="background:#E1EBF2">if ($hdr(User-Agent) =~ "xmlrpclib")</span><br>
<span style="background:#E1EBF2">set_reply_close();</span><br>
<span style="background:#E1EBF2">set_reply_no_connect();</span><br>
<span style="background:#E1EBF2">dispatch_rpc();</span><br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">send_reply("403", "Forbidden");</span><br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2"># route to voicemail server</span><br>
<span style="background:#E1EBF2">route[TOVOICEMAIL] {</span><br>
<span style="background:#E1EBF2">#!ifdef WITH_VOICEMAIL</span><br>
<span style="background:#E1EBF2">if(!is_method("INVITE"))</span><br>
<span style="background:#E1EBF2">return;</span><br>
<br>
<span style="background:#E1EBF2"># check if VoiceMail server IP is defined</span><br>
<span style="background:#E1EBF2">if (strempty($sel(cfg_get.voicemail.srv_ip))) {</span><br>
<span style="background:#E1EBF2">xlog("SCRIPT: VoiceMail rotuing enabled but IP not defined\n");</span><br>
<span style="background:#E1EBF2">return;</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">if($avp(oexten)==$null)</span><br>
<span style="background:#E1EBF2">return;</span><br>
<br>
<span style="background:#E1EBF2">$ru = "sip:" + $avp(oexten) + "@" + $sel(cfg_get.voicemail.srv_ip)</span><br>
<span style="background:#E1EBF2">+ ":" + $sel(cfg_get.voicemail.srv_port);</span><br>
<span style="background:#E1EBF2">route(RELAY);</span><br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2">return;</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<span style="background:#E1EBF2"># manage outgoing branches</span><br>
<span style="background:#E1EBF2">branch_route[MANAGE_BRANCH] {</span><br>
<span style="background:#E1EBF2">xdbg("new branch [$T_branch_idx] to $ru\n");</span><br>
<span style="background:#E1EBF2">route(NATMANAGE);</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<span style="background:#E1EBF2"># manage incoming replies</span><br>
<span style="background:#E1EBF2">onreply_route[MANAGE_REPLY] {</span><br>
<span style="background:#E1EBF2">xdbg("incoming reply\n");</span><br>
<span style="background:#E1EBF2">if(status=~"[12][0-9][0-9]")</span><br>
<span style="background:#E1EBF2">route(NATMANAGE);</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<span style="background:#E1EBF2"># manage failure routing cases</span><br>
<span style="background:#E1EBF2">failure_route[MANAGE_FAILURE] {</span><br>
<span style="background:#E1EBF2">route(NATMANAGE);</span><br>
<br>
<span style="background:#E1EBF2">if (t_is_canceled()) {</span><br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">if(t_check_status("401")) {</span><br>
<span style="background:#E1EBF2">uac_auth();</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_BLOCK3XX</span><br>
<span style="background:#E1EBF2"># block call redirect based on 3xx replies.</span><br>
<span style="background:#E1EBF2">if (t_check_status("3[0-9][0-9]")) {</span><br>
<span style="background:#E1EBF2">t_reply("404","Not found");</span><br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<br>
<span style="background:#E1EBF2">#!ifdef WITH_VOICEMAIL</span><br>
<span style="background:#E1EBF2"># serial forking</span><br>
<span style="background:#E1EBF2"># - route to voicemail on busy or no answer (timeout)</span><br>
<span style="background:#E1EBF2">if (t_check_status("486|408")) {</span><br>
<span style="background:#E1EBF2">route(TOVOICEMAIL);</span><br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">t_relay();</span><br>
<span style="background:#E1EBF2">#!endif</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<br>
<span style="background:#E1EBF2"># Test if coming from Asterisk</span><br>
<span style="background:#E1EBF2">route[FROMASTERISK] {</span><br>
<span style="background:#E1EBF2"># if($si==$sel(cfg_get.asterisk.bindip)</span><br>
<span style="background:#E1EBF2"># && $sp==$sel(cfg_get.asterisk.bindport))</span><br>
<span style="background:#E1EBF2"># return 1;</span><br>
<span style="background:#E1EBF2"># return -1;</span><br>
<br>
<span style="background:#E1EBF2"># dispatch: is this asterisk ip ?</span><br>
<span style="background:#E1EBF2">if (ds_is_from_list("1"))</span><br>
<span style="background:#E1EBF2">return 1;</span><br>
<span style="background:#E1EBF2">return -1;</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<span style="background:#E1EBF2"># Send to Asterisk</span><br>
<span style="background:#E1EBF2">route[TOASTERISK] {</span><br>
<span style="background:#E1EBF2"># $du = "sip:" + $sel(cfg_get.asterisk.bindip) + ":"</span><br>
<span style="background:#E1EBF2"># + $sel(cfg_get.asterisk.bindport);</span><br>
<span style="background:#E1EBF2"># append_hf("X-Asterisk-Context: dexter-phones\r\n");</span><br>
<span style="background:#E1EBF2"># route(RELAY);</span><br>
<span style="background:#E1EBF2"># exit;</span><br>
<span style="background:#E1EBF2"># select asterisk port</span><br>
<span style="background:#E1EBF2">append_hf("X-Asterisk-Context: dexter-phones\r\n");</span><br>
<span style="background:#E1EBF2">route(DISPATCH);</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<span style="background:#E1EBF2">route[DISPATCH] {</span><br>
<span style="background:#E1EBF2"># round robin dispatching on gateways group '1'</span><br>
<span style="background:#E1EBF2">#xlog("<<<<<<<<<<<<<<<<trying for dispatch>>>>>>>>>>>>>>>>>>>");</span><br>
<br>
<span style="background:#E1EBF2">#if (is_method("INVITE")) {</span><br>
<span style="background:#E1EBF2"># dst_select( "GROUP", "HASH METHOD")</span><br>
<span style="background:#E1EBF2">#ds_select_dst("1","4");</span><br>
<span style="background:#E1EBF2">#sl_send_reply("100","Trying");</span><br>
<span style="background:#E1EBF2"># forward();</span><br>
<span style="background:#E1EBF2"># exit();</span><br>
<span style="background:#E1EBF2">#}</span><br>
<span style="background:#E1EBF2">if (!ds_select_domain("1", "4")) {</span><br>
<span style="background:#E1EBF2">send_reply("404", "No destination");</span><br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">t_on_failure("RTF_DISPATCH");</span><br>
<span style="background:#E1EBF2">route(RELAY);</span><br>
<span style="background:#E1EBF2">exit;</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<span style="background:#E1EBF2"># Forward REGISTER to Asterisk</span><br>
<span style="background:#E1EBF2">route[REGFWD] {</span><br>
<span style="background:#E1EBF2">if(!is_method("REGISTER"))</span><br>
<span style="background:#E1EBF2">{</span><br>
<span style="background:#E1EBF2">return;</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<span style="background:#E1EBF2">$var(rip) = $sel(cfg_get.asterisk.bindip);</span><br>
<span style="background:#E1EBF2">$uac_req(method)="REGISTER";</span><br>
<span style="background:#E1EBF2">$uac_req(ruri)="sip:" + $var(rip) + ":" + $sel(cfg_get.asterisk.bindport);</span><br>
<span style="background:#E1EBF2">$uac_req(furi)="sip:" + $au + "@" + $var(rip);</span><br>
<span style="background:#E1EBF2">$uac_req(turi)="sip:" + $au + "@" + $var(rip);</span><br>
<span style="background:#E1EBF2">$uac_req(hdrs)="Contact: <<a href="sip:%22%20+%20$au%20+%20%22@%22%20+%20$sel(cfg_get.kamailio.bindip)%20+%20%22:%22%20+%20$sel(cfg_get.kamailio.bindport)%20+%20%22">sip:" + $au + "@" + $sel(cfg_get.kamailio.bindip) + ":" +
 $sel(cfg_get.kamailio.bindport) + "</a>>\r\n";</span><br>
<br>
<span style="background:#E1EBF2">if($sel(contact.expires) != $null)</span><br>
<span style="background:#E1EBF2">$uac_req(hdrs)= $uac_req(hdrs) + "Expires: " + $sel(contact.expires) + "\r\n";</span><br>
<span style="background:#E1EBF2">else</span><br>
<span style="background:#E1EBF2">$uac_req(hdrs)= $uac_req(hdrs) + "Expires: " + $hdr(Expires) + "\r\n";</span><br>
<span style="background:#E1EBF2">uac_req_send();</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<br>
<span style="background:#E1EBF2">“kamctl dispatcher dump” looks like this:</span><br>
<br>
<span style="background:#E1EBF2">{</span><br>
<span style="background:#E1EBF2">"jsonrpc": "2.0",</span><br>
<span style="background:#E1EBF2">"result": {</span><br>
<span style="background:#E1EBF2">"NRSETS": 1,</span><br>
<span style="background:#E1EBF2">"RECORDS": [{</span><br>
<span style="background:#E1EBF2">"SET": {</span><br>
<span style="background:#E1EBF2">"ID": 1,</span><br>
<span style="background:#E1EBF2">"TARGETS": [{</span><br>
<span style="background:#E1EBF2">"DEST": {</span><br>
<span style="background:#E1EBF2">"URI": "<a href="sip:ASTERISKIP:5060">sip:ASTERISKIP:5060</a>",</span><br>
<span style="background:#E1EBF2">"FLAGS": "AP",</span><br>
<span style="background:#E1EBF2">"PRIORITY": 1,</span><br>
<span style="background:#E1EBF2">"ATTRS": {</span><br>
<span style="background:#E1EBF2">"BODY": "rweight=50;weight=50;cc=1",</span><br>
<span style="background:#E1EBF2">"DUID": "",</span><br>
<span style="background:#E1EBF2">"MAXLOAD": 0,</span><br>
<span style="background:#E1EBF2">"WEIGHT": 50,</span><br>
<span style="background:#E1EBF2">"RWEIGHT": 50,</span><br>
<span style="background:#E1EBF2">"SOCKET": "",</span><br>
<span style="background:#E1EBF2">"SOCKNAME": "",</span><br>
<span style="background:#E1EBF2">"OBPROXY": ""</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">}]</span><br>
<span style="background:#E1EBF2">}</span><br>
<span style="background:#E1EBF2">}]</span><br>
<span style="background:#E1EBF2">},</span><br>
<span style="background:#E1EBF2">"id": 13403</span><br>
<span style="background:#E1EBF2">}</span><br>
<br>
<span style="background:#E1EBF2">And also have set trunk in ASTERISK sip.conf</span><br>
<br>
<span style="background:#E1EBF2">register => kamailioSIP:XXXX@KamailioIP:5060</span><br>
<br>
<span style="background:#E1EBF2">[kamailio]</span><br>
<span style="background:#E1EBF2">type=friend</span><br>
<span style="background:#E1EBF2">host= KamailioIP</span><br>
<span style="background:#E1EBF2">port=5060</span><br>
<span style="background:#E1EBF2">transport=udp</span><br>
<span style="background:#E1EBF2">allow=all</span><br>
<span style="background:#E1EBF2">allow=gsm</span><br>
<span style="background:#E1EBF2">allow=alaw,ulaw</span><br>
<span style="background:#E1EBF2">insecure=invite,port</span><br>
<span style="background:#E1EBF2">Permit = <a href="http://0.0.0.0/0.0.0.0">0.0.0.0/0.0.0.0</a></span><br>
<span style="background:#E1EBF2">sipdebug=yes</span><br>
<span style="background:#E1EBF2">username=kamailioSIP</span><br>
<span style="background:#E1EBF2">canreinvite=no</span><br>
<span style="background:#E1EBF2">secret=XXXX</span><br>
<span style="background:#E1EBF2">qualify=yes</span><br>
<span style="background:#E1EBF2">dtmfmode=auto</span></span><o:p></o:p></p>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><span style="font-size:10.0pt;font-family:"Trebuchet MS",sans-serif;color:#333333;background:#ECF3F7">when i Register my asterisk devices with kamailioIP (and I am able to do this)</span><span style="font-size:10.0pt;font-family:"Trebuchet MS",sans-serif;color:#333333"><br>
<span style="background:#ECF3F7">Devices are getting register with the asterisk from with kamailioIP asterisk -r : (here 8101 and 8100 is registered with Kamailio IP )</span><br>
<br>
<span style="background:#ECF3F7">[Nov 9 10:36:02] -- Registered SIP '8101' at XX.XX.XX.95:5060</span><br>
<span style="background:#ECF3F7">[Nov 9 10:36:02] -- Unregistered SIP '8101'</span><br>
<span style="background:#ECF3F7">[Nov 9 10:36:03] -- Registered SIP '8101' at XX.XX.XX..95:5060</span><br>
<span style="background:#ECF3F7">[Nov 9 10:36:03] == Manager 'listencron' logged on from 127.0.0.1</span><br>
<span style="background:#ECF3F7">[Nov 9 10:36:04] == Manager 'sendcron' logged off from 127.0.0.1</span><br>
<span style="background:#ECF3F7">[Nov 9 10:36:07] -- Unregistered SIP '8100'</span><br>
<span style="background:#ECF3F7">[Nov 9 10:36:09] -- Registered SIP '8100' at XX.XX.XX..95:5060</span><br>
<span style="background:#ECF3F7">[Nov 9 10:36:09] > Saved useragent "Z 3.15.40006 rv2.8.20" for peer 8100</span><br>
<span style="background:#ECF3F7">[Nov 9 10:36:09] NOTICE[8453]: chan_sip.c:23869 handle_response_peerpoke: Peer '8100' is now</span><br>
<span style="background:#ECF3F7">Reachable. (51ms / 2000ms)</span><br>
<br>
<br>
<span style="background:#ECF3F7">when i dial 8100 to 8101 i get in my asteris -r</span><br>
<br>
<span style="background:#ECF3F7">NOTICE[8453][C-0000000b]: chan_sip.c:26002 handle_request_invite: Call from '8101' (<a href="http://95.217.223.95:5060">95.217.223.95:5060</a>) to extension '8100' rejected because extension not found in context 'none-dial'.</span><br>
<br>
<span style="background:#ECF3F7">and not able to call extension to extension,</span></span>  <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:35.4pt"><span style="font-size:10.0pt;font-family:"Trebuchet MS",sans-serif;color:black"><br>
<br>
<span style="background:#E1EBF2">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.</span><br>
<span style="background:#E1EBF2">I will be eagerly waiting for any help or pointer…</span><br>
<br>
<span style="background:#E1EBF2">Thanks in advance</span></span>  <o:p></o:p></p>
</div>
</div>
</div>
</body>
</html>