Blogs on System Administration, Scripting, System Monitoring, Cloud Computing & Virtualizaton, VoIP Systems, SMS Systems and Web Applications Development.

How to install Kannel in Centos 7?


This article is to give an overview to install Kannel as SMS gateway with MySQL Support.


In this article, we are installing latest Kannel version 1.4.4 in Centos 7.


Before starting installation Process, Install some of the dependencies of Kannel:
$ sudo yum update
$ sudo yum groupinstall "Development tools" -y
$ sudo yum install libxml2-devel
Following is the step by step guide for installing Kannel from source.

Step # 1

Download and extract FreeSWITCH source:
$ cd /usr/local/src/
$ sudo wget
$ sudo tar -zxvf gateway-1.4.4.tar.gz

Step # 2

Compile & Install Kannel with MySQL support:
$ cd /usr/local/src/gateway-1.4.4
$ sudo ./configure  --prefix=/etc/kannel --enable-start-stop-daemon
$ sudo make
$ sudo make install

Step # 3

Create path for SMSCs, logs and PID files:
$ sudo mkdir /etc/kannel/smscs
$ sudo mkdir /etc/kannel/logs
$ sudo mkdir /etc/kannel/run

Step # 4

Create main configuration file for Kannel i.e. kannel.conf
$ sudo vi /etc/kannel/kannel.conf
# kannel.conf
group = core
dlr-storage = internal
admin-port = 14000
admin-password = <admin-password>
status-password = <status-password>
admin-allow-ip = '*.*.*.*'
smsbox-port = 14004
log-level = 0
log-file = "/etc/kannel/logs/kannel.log"
box-allow-ip = "*.*.*.*"
# Here you can add as many SMSC you want and it will he easy to disable any SMSC
include = "/etc/kannel/smscs/smsc01.conf"
group = smsbox
smsbox-id = BOX1
bearerbox-host = X.X.X.X
sendsms-port = 14013
log-file = "/etc/kannel/logs/smsbox.log"
log-level = 0
access-log = "/etc/kannel/logs/access.log"
group = smsbox-route
smsbox-id = BOX1
smsc-id = SMSC01    
# For Receiving SMS
group = sms-service
keyword = default
catch-all = yes
max-messages = 0
# For Sending SMS
group = sendsms-user
username = <set-username-for-sending-sms>
password = <set-password-for-sending-sms>
#dlr-url = "http://someurl?"
default-smsc = SMSC01
concatenation= true
max-messages = 2
#forced-smsc = "SMSC01"

Step # 5

Create an SMSC file for the kannel
$ sudo vi /etc/kannel/smscs/smsc1.conf
group = smsc
smsc = smpp
smsc-id = SMSC01
host = <smsc-host>
port = <smsc-port>
system-id = <username>
smsc-password = <password>
system-type = SMPP
transceiver-mode = true
log-file = "/etc/kannel/logs/smsc01.log"
allowed-smsc-id = SMSC01

Step # 6

Create kannel init script:
$ sudo touch /etc/init.d/kannel
$ sudo chmod a+x /etc/init.d/kannel
$ sudo vi /etc/init.d/kannel

Add following code in init script of kannel:
# Start/stop the Kannel boxes: One bearer box and one WAP box.
# This is the default init.d script for Kannel.  Its configuration is
# appropriate for a small site running Kannel on one machine.
# Make sure that the Kannel binaries can be found in $BOXPATH or somewhere
# else along $PATH.  run_kannel_box has to be in $BOXPATH.
# On Debian, the most likely reason for the bearerbox not being available
# is that the package is in the "removed" or "unconfigured" state, and the
# init.d script is still around because it's a conffile.  This is normal,
# so don't generate any output.
#test -x $BOXPATH/$BB || exit 0
case "$1" in
    echo -n "Starting WAP gateway: bearerbox"
    $SSD --start --quiet --pidfile $PIDFILES/ --exec $RB -- --pidfile $PIDFILES/ $BB -- $CONF
    echo -n " smsbox"
    $SSD --start --quiet --pidfile $PIDFILES/ --exec $RB -- --pidfile $PIDFILES/ $SB -- $CONF
    echo "."
    echo -n "Stopping WAP gateway: "
    echo -n " smsbox"
    $SSD --stop --quiet --pidfile $PIDFILES/ --exec $RB
    echo -n " bearerbox"
    $SSD --stop --quiet --pidfile $PIDFILES/ --exec $RB
    echo "."
    CORE_CONF=$(grep -r 'group[[:space:]]*=[[:space:]]*core' $CONFDIR | cut -d: -f1)
    ADMIN_PORT=$(grep '^admin-port' $CORE_CONF | sed "s/.*=[[:space:]]*//")
    ADMIN_PASS=$(grep '^admin-password' $CORE_CONF | sed "s/.*=[[:space:]]*//")
    lynx -source $STATUS_URL
    # We don't have support for this yet.
    exit 1
    $0 stop
    sleep 1
    $0 start
    echo "Usage: $0 {start|stop|status|reload|restart|force-reload}"
    exit 1
exit 0

Step # 7

Starting kannel:
$ sudo service kannel start
Starting WAP gateway: bearerbox smsbox.

Verifying kannel Status
$ ps aux | grep kannel
root      2233  0.0  0.0  53172   684 ?        Ss   21:04   0:00 /etc/kannel/sbin/run_kannel_box --pidfile /etc/kannel/run/ /etc/kannel/sbin/bearerbox -- /etc/kannel/kannel.conf
root      2235  0.0  0.1 384412  5712 ?        Sl   21:04   0:00 /etc/kannel/sbin/bearerbox -v 4 -- /etc/kannel/kannel.conf
root      2236  0.0  0.0  53172   744 ?        Ss   21:04   0:00 /etc/kannel/sbin/run_kannel_box --pidfile /etc/kannel/run/ /etc/kannel/sbin/smsbox -- /etc/kannel/kannel.conf
root     15412  0.0  0.1 377076  4120 ?        Sl   21:47   0:00 /etc/kannel/sbin/smsbox -v 4 -- /etc/kannel/kannel.conf
$ netstat -pln | grep box
tcp        0      0     *                   LISTEN      15412/smsbox       
tcp        0      0     *                   LISTEN      2235/bearerbox     
tcp        0      0     *                   LISTEN      2235/bearerbox

Now Kannel v1.4.4 has been successfully installed in Centos 7.

Step # 8

Check Kannel status

Following is the URL to send SMS via Kannel:


  1. thanks, you have been great help

  2. I think only one printing mistake is there in kannel.conf
    Instead of include = "/etc/kannel/smscs/smsc01.conf"
    it should be include = "/etc/kannel/smscs/smsc1.conf"
    Of course I have not yet fully configured it.
    curl 'http://X.X.X.X:14000/status?password=:14013; Connection refused.
    Please Help

    1. This comment has been removed by the author.

    2. Same problem here although i was installing 1.4.5 and installed and configured entire kannel.conf to work with gsm modem. But after finishing installation i tried curl request but it failed i checked firewald multiple time all the required ports were opened on both tcp and udp but smsbox and bearerbox was not listening on those ports. And then I dont know how suddenly kennel started working for few minutes after that it failed again when i restarted the service. Checked kannel.conf & firewal rules multiple times but no luck. Now i am starting again from scratch to see where it went wrong.

  3. Status is showing OK in curl command.
    But while sending SMS it shows, connection refused.
    Please Help.

    1. Check smsbox configurations in kannel.conf and check if the port is not closed.. Connection refused usually means no process is listing on that port. To confirm this try this command as root:

      netstat -nlp | grep box

    2. Sorry its

      netstat -pln | grep box

  4. In the post you are stating that you are installing kennel with mysql support but instead you are compiling it without mysql support.

    This line
    ./configure --prefix=/etc/kannel --enable-start-stop-daemon
    ./configure --prefix=/etc/kannel --enable-start-stop-daemon --with-mysql

  5. *
    This line:
    ./configure --prefix=/etc/kannel --enable-start-stop-daemon

    Should be:
    ./configure --prefix=/etc/kannel --enable-start-stop-daemon --with-mysql

    Kindly fix this in the post as it can be little bit problematic for script kiddies like me.

    But Anyways thanks for this post I am currently following this to install kennel on a test build.

  6. With business texting service USA, you also get the option of setting a customer signature that appears after every message you send. This is an excellent way to promote your business and it can be used as part of a marketing strategy.


  7. Hello
    I have a question, I need some help
    => I need a solution that allows the user when he connects to a wifi guest to enter your number after receiving a code for access, a captive portal with SMS Gateway

  8. Hi guys i want to ask question how to connect coz

    ill try to run this command

    curl 'http://myip:14000/status?password='

    and then the result is

    curl: (7) couldn't connect to host

    how to fix this thanks.

    1. change 14000, 15000 there is port issue to be handled

  9. Hi all run this command
    curl 'http://localhost:13000/status?password=*****'
    and result is

  10. Hello,when i was restarting the kannel service it ws throwing error as :

    Starting WAP gateway: bearerbox/etc/init.d/kannel: line 36: /usr/local/sbin/start-stop-daemon: No such file or directory
    smsbox/etc/init.d/kannel: line 38: /usr/local/sbin/start-stop-daemon: No such file or directory.
    And run_kannel_box ,wapbox,smsbox,bearerbox was in the directory /usr/local/sbin and boxpath was also in same directory.What could be error?It's searching for some file or directory?Can u please help me to figure out this problem?

  11. "sudo make" giving below error:

    sudo make
    gcc -std=gnu99 -D_REENTRANT=1 -I. -Igw -g -O2 -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_LARGE_FILES= -I/usr/include/libxml2 -o wmlscript/wsgram.o -c wmlscript/wsgram.c error: conflicting types for âws_yy_parseâ
    In file included from wmlscript/wsgram.y:15:0:
    ./wmlscript/wsint.h:296:5: note: previous declaration of âws_yy_parseâ was here
    int ws_yy_parse(void *context);
    wmlscript/wsgram.c:63:25: error: conflicting types for âws_yy_parseâ
    #define yyparse ws_yy_parse
    ^ note: in expansion of macro âyyparseâ
    In file included from wmlscript/wsgram.y:15:0:
    ./wmlscript/wsint.h:296:5: note: previous declaration of âws_yy_parseâ was here
    int ws_yy_parse(void *context);
    wmlscript/wsgram.y: In function âws_yy_parseâ:
    wmlscript/wsgram.y:122:23: error: âpctxâ undeclared (first use in this function)
    { ws_error_syntax(pctx, @1.first_line); }
    wmlscript/wsgram.y:122:23: note: each undeclared identifier is reported only once for each function it appears in
    make: *** [wmlscript/wsgram.o] Error 1

    1. Help
      curl http://localhost:13013/cgi-bin/sendsms?username=tester&password=foobar&from=100&to=2121&text=hello

      ]# Authorization failed for sendsms

      [1] 13295
      [2] 13296
      [3] 13297
      [4] 13298
      [2] Done password=foobar
      [3]- Done from=100 [test]# Authorization failed for sendsms
      [1]- Done curl http://localhost:13013/cgi-bin/sendsms?username=tester
      [4]+ Done to=2121

    2. try this works for me

  12. Hello friends need help.
    SMS PID need to pass for Net Core SMS Vendor, where can i add my PID numner bcz my sms are getting undeliver & rejected.


Please Enter your Comments Here.