Actually, I am not a guy works in telecommunication technology. But I know about SIP when I was a student in University. Recently, I had a task install Kamailio for Mobile Team can make a test call via SIP. I would like to record the steps here.
Kamailio
The first step, we add apt-key with command:
1 |
curl http://deb.kamailio.org/kamailiodebkey.gpg | apt-key add - |
Add the package to source.list file (I am using Debian Jessie)
1 2 |
echo "deb http://deb.kamailio.org/kamailio jessie main" > /etc/apt/sources.list.d/kamailio.list echo "deb-src http://deb.kamailio.org/kamailio jessie main" >> /etc/apt/sources.list.d/kamailio.list |
For the other version: https://www.kamailio.org/wiki/packages/debs
Install:
1 2 |
apt-get update apt-get -y install kamailio kamailio-extra-modules kamailio-ims-modules kamailio-mysql-modules kamailio-nth kamailio-presence-modules kamailio-tls-modules kamailio-websocket-modules kamailio-xml-modules kamailio-xmpp-modules |
After finishing the installation, you have to edit /etc/default/kamailio file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# # Kamailio startup options # # Set to yes to enable kamailio, once configured properly. RUN_KAMAILIO=yes # User to run as USER=root # Group to run as GROUP=root # Amount of shared and private memory to allocate # for the running Kamailio server (in Mb) #SHM_MEMORY=64 #PKG_MEMORY=8 # Config file CFGFILE=/etc/kamailio/kamailio.cfg # Enable the server to leave a core file when it crashes. # Set this to 'yes' to enable Kamailio to leave a core file when it crashes # or 'no' to disable this feature. This option is case sensitive and only # accepts 'yes' and 'no' and only in lowercase letters. # On some systems it is necessary to specify a directory for the core files # to get a dump. Look into the kamailio init file for an example configuration. DUMP_CORE=yes |
Restart Kamailio:
1 |
/etc/init.d/kamailio restart |
Kamailio and Mysql
In my case, I used Mysql DB with Kamailio. So I install mysql:
1 |
sudo apt-get intall mysql-server |
And you have change /etc/kamailio/kamctl to setup Kamailo connect with Mysql
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# $Id$ # # The Kamailio configuration file for the control tools. # # Here you can set variables used in the kamctl and kamdbctl setup # scripts. Per default all variables here are commented out, the control tools # will use their internal default values. ## your SIP domain SIP_DOMAIN=sigma.sip ## chrooted directory # $CHROOT_DIR="/path/to/chrooted/directory" ## database type: MYSQL, PGSQL, ORACLE, DB_BERKELEY, DBTEXT, or SQLITE # by default none is loaded # # If you want to setup a database with kamdbctl, you must at least specify # this parameter. DBENGINE=MYSQL ## database host DBHOST=localhost ## database name (for ORACLE this is TNS name) DBNAME=kamailio # database path used by dbtext, db_berkeley or sqlite # DB_PATH="/usr/local/etc/kamailio/dbtext" ## database read/write user DBRWUSER="root" ## password for database read/write user DBRWPW="pass" ## database read only user DBROUSER="root" ## password for database read only user DBROPW="pass" ## database access host (from where is kamctl used) # DBACCESSHOST=192.168.0.1 ## database super user (for ORACLE this is 'scheme-creator' user) # DBROOTUSER="root" # user name column # USERCOL="username" # SQL definitions # If you change this definitions here, then you must change them # in db/schema/entities.xml too. # FIXME # FOREVER="2030-05-28 21:32:15" # DEFAULT_Q="1.0" # Program to calculate a message-digest fingerprint # MD5="md5sum" # awk tool # AWK="awk" # gdb tool # GDB="gdb" # If you use a system with a grep and egrep that is not 100% gnu grep compatible, # e.g. solaris, install the gnu grep (ggrep) and specify this below. # # grep tool # GREP="grep" # egrep tool # EGREP="egrep" # sed tool # SED="sed" # tail tool # LAST_LINE="tail -n 1" # expr tool # EXPR="expr" # Describe what additional tables to install. Valid values for the variables # below are yes/no/ask. With ask (default) it will interactively ask the user # for an answer, while yes/no allow for automated, unassisted installs. # # If to install tables for the modules in the EXTRA_MODULES variable. # INSTALL_EXTRA_TABLES=ask # If to install presence related tables. # INSTALL_PRESENCE_TABLES=ask # If to install uid modules related tables. # INSTALL_DBUID_TABLES=ask # Define what module tables should be installed. # If you use the postgres database and want to change the installed tables, then you # must also adjust the STANDARD_TABLES or EXTRA_TABLES variable accordingly in the # kamdbctl.base script. # Kamailio standard modules # STANDARD_MODULES="standard acc lcr domain group permissions registrar usrloc msilo # alias_db uri_db speeddial avpops auth_db pdt dialog dispatcher # dialplan" # Kamailio extra modules # EXTRA_MODULES="imc cpl siptrace domainpolicy carrierroute userblacklist htable purple sca" ## type of aliases used: DB - database aliases; UL - usrloc aliases ## - default: none ALIASES_TYPE="DB" ## control engine: FIFO or UNIXSOCK ## - default FIFO CTLENGINE="FIFO" ## path to FIFO file # FIFOPATH="/var/run/kamailio/kamailio_fifo" ## check ACL names; default on (1); off (0) # VERIFY_ACL=1 ## ACL names - if VERIFY_ACL is set, only the ACL names from below list ## are accepted # ACL_GROUPS="local ld int voicemail free-pstn" ## verbose - debug purposes - default '0' VERBOSE=1 ## do (1) or don't (0) store plaintext passwords ## in the subscriber table - default '1' # STORE_PLAINTEXT_PW=0 ## Kamailio START Options ## PID file path - default is: /var/run/kamailio.pid PID_FILE=/var/run/kamailio/kamailio.pid ## Extra start options - default is: not set # example: start Kamailio with 64MB share memory: STARTOPTIONS="-m 64" # STARTOPTIONS= |
And you should initiate database for Kamailio on Mysql now:
1 |
kamdbctl create |
Add the first SIP account with command:
1 |
kamctl add bob pass |
Show the list of the subscribers:
1 |
kamctl db show subscriber |
Now, you can install a SIP client to test your SIP server. I suggest you use Jitsi
To troubleshoot your calls, you can use tcpdump, lsof command. And show Kamailio logs (tail -f /var/log/syslogs)
TLS
At the first, we should change /etc/kamailio/kamailio.cfg by adding a line:
1 |
#!define WITH_TLS |
And restart Kamailio.
To verify, we can use lsof command:
1 |
lsof -i :5061 |
Thanks for your reading!!!