<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:Verdana;
        panose-1:2 11 6 4 3 5 4 4 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:#0563C1;
        text-decoration:underline;}
span.E-MailFormatvorlage20
        {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="#0563C1" vlink="#954F72" 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">yes, DB connection is usually straight forward.<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">Do you see any errors in the mysql server logs? Any errors visible with some network debugging tools?<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 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>
<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>Youssef Boujraf<br>
<b>Sent:</b> Monday, March 28, 2022 5:47 PM<br>
<b>To:</b> sr-users@lists.kamailio.org<br>
<b>Subject:</b> [SR-Users] kamailio - mariadb hosted on remote server - issue<o:p></o:p></p>
</div>
<p class="MsoNormal" style="margin-left:35.4pt"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-left:35.4pt">Dear all,<br>
<br>
I don't belive to connect Kamailio to a remote Mariadb will take too much time.<br>
<br>
<br>
STEP 1 : KAMAILIO :<br>
--------------------------------<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p style="margin-left:35.4pt">$ sudo kamailio -v<br>
version: kamailio 5.5.4 (x86_64/linux)<br>
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLOCKLIST,
 HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED<br>
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB<br>
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.<br>
id: unknown<br>
compiled with gcc 10.2.1<o:p></o:p></p>
</blockquote>
<p class="MsoNormal" style="margin-left:35.4pt"><br>
STEP 2 : Set the kamctlrc config<br>
------------------------------------------------<br>
<br>
KAMAILIO IP : 192.168.1.41<br>
MARIADB IP : 192.168.1.39<br>
<br>
- /etc/kamailio/kamctlrc<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p style="margin-left:35.4pt">SIP_DOMAIN=example.be<br>
DBENGINE=MYSQL<br>
DBHOST=192.168.1.39 // where the mariadb is installed<br>
DBNAME=kamailio<br>
DBRWUSER="kamailio"<br>
DBRWPW="XX"<br>
DBROUSER="kamailioro"<br>
DBROPW="XX"<br>
DBACCESSHOST=192.168.1.41 // where kamctl is launched (here kamailio srv)<br>
DBROOTUSER="root"<br>
DBROOTPW="kamailio"<br>
CHARSET="latin1"<o:p></o:p></p>
</blockquote>
<p class="MsoNormal" style="margin-left:35.4pt"><br>
STEP 3 : MARIADB : hosted on different srv than kamailio<br>
--------------------------------------------------------------------------------------<br>
<br>
IP : 192.168.1.39<br>
<br>
- /etc/mysql/mariadb.conf.d/50-server.cnf<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p style="margin-left:35.4pt"># this is only for the mysqld standalone daemon<br>
[mysqld]<br>
<br>
# Instead of skip-networking the default is now to listen only on<br>
# localhost which is more compatible and is not less secure.<br>
#bind-address            = 127.0.0.1<br>
bind-address            = 0.0.0.0<o:p></o:p></p>
</blockquote>
<p class="MsoNormal" style="margin-left:35.4pt"><br>
<br>
STEP 4 : TEST : Reote connection with the DB<br>
----------------------------------------------------------------------<br>
<br>
REMOTE IP : 192.168.1.41<br>
DB IP : 192.168.1.39<br>
 <o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p style="margin-left:35.4pt"><br>
$ sudo mysql -u root -h 192.168.1.39 -p<br>
Enter password:<br>
Welcome to the MariaDB monitor.  Commands end with ; or \g.<br>
Your MariaDB connection id is 298<br>
Server version: 10.5.15-MariaDB-1:10.5.15+maria~bullseye mariadb.org binary distribution<br>
<br>
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.<br>
<br>
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.<br>
<br>
MariaDB [(none)]><o:p></o:p></p>
</blockquote>
<p class="MsoNormal" style="margin-left:35.4pt">The connection is established with success.<br>
<br>
<br>
STEP 5 : KAMAILIO DB : creation<br>
----------------------------------------------------<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p style="margin-left:35.4pt">$ sudo kamdbctl create<br>
-e \E[37;33mINFO: creating database kamailio ...<br>
-e \E[37;33mINFO: granting privileges to database kamailio ...<br>
-e \E[37;33mINFO: creating standard tables into kamailio ...<br>
-e \E[37;33mINFO: Core Kamailio tables successfully created.<br>
Create the presence related tables? (y/n): y<br>
-e \E[37;33mINFO: creating presence tables into kamailio ...<br>
-e \E[37;33mINFO: Presence tables successfully created.<br>
Create the tables for imc cpl siptrace domainpolicy carrierroute<br>
                drouting userblocklist htable purple uac pipelimit mtree sca mohqueue<br>
                rtpproxy rtpengine secfilter? (y/n): y<br>
-e \E[37;33mINFO: creating extra tables into kamailio ...<br>
-e \E[37;33mINFO: Extra tables successfully created.<br>
Create the tables for uid_auth_db uid_avp_db uid_domain uid_gflags<br>
                uid_uri_db? (y/n): y<br>
-e \E[37;33mINFO: creating uid tables into kamailio ...<br>
-e \E[37;33mINFO: UID tables successfully created.<o:p></o:p></p>
</blockquote>
<p class="MsoNormal" style="margin-left:35.4pt"><br>
STEP 6 : DB : verify the users creation and rights<br>
--------------------------------------------------------------------------<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p style="margin-left:35.4pt">MariaDB [(none)]> select user, host from mysql.user;<br>
+-------------+--------------+<br>
| User        | Host         |<br>
+-------------+--------------+<br>
| kamailio    | 192.168.1.39 |<br>
| kamailioro  | 192.168.1.39 |<br>
| kamailio    | 192.168.1.41 |<br>
| kamailioro  | 192.168.1.41 |<br>
| root        | 192.168.1.41 |<br>
| kamailio    | localhost    |<br>
| kamailioro  | localhost    |<br>
| mariadb.sys | localhost    |<br>
| mysql       | localhost    |<br>
| root        | localhost    |<br>
+-------------+--------------+<br>
10 rows in set (0.001 sec)<br>
<br>
MariaDB [(none)]> SHOW GRANTS FOR <a href="mailto:kamailio@192.168.1.41">kamailio@192.168.1.41</a>;<br>
+--------------------------------------------------------------------------------------------------------------------+<br>
| Grants for <a href="mailto:kamailio@192.168.1.41">kamailio@192.168.1.41</a>                                                                                   |<br>
+--------------------------------------------------------------------------------------------------------------------+<br>
| GRANT USAGE ON *.* TO `kamailio`@`192.168.1.41` IDENTIFIED BY PASSWORD '*157PASSWORD' |<br>
| GRANT ALL PRIVILEGES ON `kamailio`.* TO `kamailio`@`192.168.1.41`                                                  |<br>
+--------------------------------------------------------------------------------------------------------------------+<br>
2 rows in set (0.000 sec)<br>
<br>
MariaDB [(none)]> SHOW GRANTS FOR <a href="mailto:kamailio@192.168.1.39">kamailio@192.168.1.39</a>;<br>
+--------------------------------------------------------------------------------------------------------------------+<br>
| Grants for <a href="mailto:kamailio@192.168.1.39">kamailio@192.168.1.39</a>                                                                                   |<br>
+--------------------------------------------------------------------------------------------------------------------+<br>
| GRANT USAGE ON *.* TO `kamailio`@`192.168.1.39` IDENTIFIED BY PASSWORD '*157PASSWORD' |<br>
| GRANT ALL PRIVILEGES ON `kamailio`.* TO `kamailio`@`192.168.1.39`                                                  |<br>
+--------------------------------------------------------------------------------------------------------------------+<br>
2 rows in set (0.000 sec)<br>
<br>
MariaDB [(none)]> SHOW GRANTS FOR kamailio@localhost;<br>
+-----------------------------------------------------------------------------------------------------------------+<br>
| Grants for kamailio@localhost                                                                                   |<br>
+-----------------------------------------------------------------------------------------------------------------+<br>
| GRANT USAGE ON *.* TO `kamailio`@`localhost` IDENTIFIED BY PASSWORD '*157PASSWORD' |<br>
| GRANT ALL PRIVILEGES ON `kamailio`.* TO `kamailio`@`localhost`                                                  |<br>
+-----------------------------------------------------------------------------------------------------------------+<br>
2 rows in set (0.000 sec)<o:p></o:p></p>
</blockquote>
<p class="MsoNormal" style="margin-left:35.4pt">STEP 7 : ADDRESS TABLE : add new ip address<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal" style="margin-left:35.4pt">$ sudo systemctl restart kamailio<br>
sipsecure@kamailio:/etc$ sudo kamctl address add 0 192.168.1.26 32 0 HP<br>
-e \E[37;33mINFO: execute '/sbin/kamctl address reload' to synchronize cache and database<o:p></o:p></p>
<p style="margin-left:35.4pt"> <o:p></o:p></p>
</blockquote>
<p class="MsoNormal" style="margin-left:35.4pt"><br>
STEP 8 : DB : verify if the new ip address is created ? Yes<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p style="margin-left:35.4pt">MariaDB [(none)]> select * from kamailio.address;<br>
+----+-----+--------------+------+------+------+<br>
| id | grp | ip_addr      | mask | port | tag  |<br>
+----+-----+--------------+------+------+------+<br>
|  1 |   0 | 192.168.1.26 |   32 |    0 | HP   |<br>
+----+-----+--------------+------+------+------+<br>
1 row in set (0.000 sec)<o:p></o:p></p>
</blockquote>
<p class="MsoNormal" style="margin-left:35.4pt"><br>
STEP 9 : Reload the content of the DB into kamailio. It failed<br>
----------------------------------------------------------------------------------------<br>
<br>
The host: '192.168.1.41' is kamailio (remote client)<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal" style="margin-left:35.4pt">$ sudo kamctl address reload<br>
{<br>
  "jsonrpc":  "2.0",<br>
  "error":  {<br>
    "code": 500,<br>
    "message":  "Reload failed."<br>
  },<br>
  "id": 12397<br>
}<o:p></o:p></p>
<p style="margin-left:35.4pt"> <o:p></o:p></p>
</blockquote>
<p class="MsoNormal" style="margin-left:35.4pt">In /var/log/daemon.log<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p style="margin-left:35.4pt">Mar 28 17:09:49 db04srv mariadbd[2430]: 2022-03-28 17:09:49 281 [Warning] Aborted connection 281 to db: 'kamailio' user: 'kamailio' host: '192.168.1.41' (Got an error reading communication packets)<br>
Mar 28 17:09:49 db04srv mariadbd[2430]: 2022-03-28 17:09:49 273 [Warning] Aborted connection 273 to db: 'kamailio' user: 'kamailio' host: '192.168.1.41' (Got an error reading communication packets)<br>
Mar 28 17:09:49 db04srv mariadbd[2430]: 2022-03-28 17:09:49 295 [Warning] Aborted connection 295 to db: 'kamailio' user: 'kamailio' host: '192.168.1.41' (Got an error reading communication packets)<br>
Mar 28 17:09:49 db04srv mariadbd[2430]: 2022-03-28 17:09:49 264 [Warning] Aborted connection 264 to db: 'kamailio' user: 'kamailio' host: '192.168.1.41' (Got an error reading communication packets)<o:p></o:p></p>
</blockquote>
<p class="MsoNormal" style="margin-left:35.4pt"><br>
Now, if I am trying to restart "kamailio" service, I got an error :<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p style="margin-left:35.4pt">Mar 28 17:36:30 kamailio /usr/sbin/kamailio[14196]: DEBUG: <core> [core/sr_module.c:940]: init_mod(): permissions<br>
Mar 28 17:36:30 kamailio /usr/sbin/kamailio[14196]: DEBUG: permissions [address.c:179]: reload_address_db_table(): Number of rows in address table: 1<br>
Mar 28 17:36:30 kamailio /usr/sbin/kamailio[14196]: DEBUG: permissions [address.c:191]: reload_address_db_table(): failure during checks of database value 1 (group) in address table<br>
Mar 28 17:36:30 kamailio /usr/sbin/kamailio[14196]: ERROR: permissions [address.c:233]: reload_address_db_table(): database problem - invalid record<br>
Mar 28 17:36:30 kamailio /usr/sbin/kamailio[14196]: CRITICAL: permissions [address.c:536]: init_addresses(): reload of address table failed<br>
Mar 28 17:36:30 kamailio /usr/sbin/kamailio[14196]: ERROR: permissions [permissions.c:657]: mod_init(): failed to initialize the allow_address function<br>
Mar 28 17:36:30 kamailio /usr/sbin/kamailio[14196]: ERROR: <core> [core/sr_module.c:942]: init_mod(): Error while initializing module permissions (/usr/lib/x86_64-linux-gnu/kamailio/modules/permissions.so)<br>
Mar 28 17:36:30 kamailio kamailio: DEBUG: <core> [core/cfg.y:1860]: yyparse(): loading module permissions.so<br>
Mar 28 17:36:30 kamailio kamailio: DEBUG: <core> [core/sr_module.c:513]: ksr_locate_module(): found module to load </usr/lib/x86_64-linux-gnu/kamailio/modules/permissions.so><br>
Mar 28 17:36:30 kamailio kamailio: DEBUG: <core> [core/sr_module.c:563]: load_module(): trying to load </usr/lib/x86_64-linux-gnu/kamailio/modules/permissions.so><br>
Mar 28 17:36:30 kamailio kamailio: DEBUG: <core> [core/kemi.c:3090]: sr_kemi_modules_add(): adding module: permissions<br>
Mar 28 17:36:30 kamailio kamailio: DEBUG: <core> [core/cfg.lex:1963]: pp_define(): defining id: MOD_permissions<br>
Mar 28 17:36:30 kamailio kamailio: DEBUG: <core> [core/modparam.c:112]: set_mod_param_regex(): 'permissions' matches module 'permissions'<br>
Mar 28 17:36:30 kamailio kamailio: DEBUG: <core> [core/sr_module.c:811]: find_param_export(): found <db_url> in module permissions [/usr/lib/x86_64-linux-gnu/kamailio/modules/permissions.so]<br>
Mar 28 17:36:30 kamailio kamailio: DEBUG: <core> [core/modparam.c:128]: set_mod_param_regex(): found <db_url> in module permissions [/usr/lib/x86_64-linux-gnu/kamailio/modules/permissions.so]<br>
Mar 28 17:36:30 kamailio kamailio: DEBUG: <core> [core/modparam.c:112]: set_mod_param_regex(): 'permissions' matches module 'permissions'<br>
Mar 28 17:36:30 kamailio kamailio: DEBUG: <core> [core/sr_module.c:811]: find_param_export(): found <load_backends> in module permissions [/usr/lib/x86_64-linux-gnu/kamailio/modules/permissions.so]<br>
Mar 28 17:36:30 kamailio kamailio: DEBUG: <core> [core/modparam.c:128]: set_mod_param_regex(): found <load_backends> in module permissions [/usr/lib/x86_64-linux-gnu/kamailio/modules/permissions.so]<br>
Mar 28 17:36:31 kamailio kamailio: DEBUG: <core> [core/sr_module.c:719]: find_mod_export_record(): found export of <allow_source_address> in module permissions [/usr/lib/x86_64-linux-gnu/kamailio/modules/permissions.so]<br>
Mar 28 17:36:31 kamailio kamailio: DEBUG: <core> [core/sr_module.c:719]: find_mod_export_record(): found export of <allow_source_address_group> in module permissions [/usr/lib/x86_64-linux-gnu/kamailio/modules/permissions.so<o:p></o:p></p>
</blockquote>
<p class="MsoNormal" style="margin-left:35.4pt">If I remove the record from the database manually, I can restart kamailio but no way to add any address.<br>
<br>
Thanks if someone could highlight my path.<br>
<br>
Best Regards,<br>
<br>
--<br>
<b><span lang="EN-US" style="font-size:10.0pt;font-family:"Verdana",sans-serif;color:#1F497D">Youssef
</span></b><o:p></o:p></p>
</div>
</body>
</html>