Thursday, 1 September 2011

Installing and configuring Kannel SMS Gateway


Kannel is an open source SMS and WAP gateway. It's freely available software used by operators, carriers, mobile aggregators and other users to send and receive SMS messages and mobile content.
Further details of Kannel can be found at Kannel's Website . There are many different ways to implement Kannel so it depends what your need is.

A lot of users setup Kannel to connect to HTTP and SMPP providers in order to send SMS messages. In this post I will show how to install, configure and send your first SMS using the gateway

For reference, the user guide can be found at http://www.kannel.com/userguide.shtml

1. Firstly ensure all software requirements are installed and then download the source from the Kannel Download site.

wget http://www.kannel.com/download/1.4.3/gateway-1.4.3.tar.gz

2. Extract the archive file to directory.

tar -xzvf gateway-1.4.3.tar.gz

3. Change to the directory to compile

cd gateway-1.4.3

We want to install to /usr/local so we complete the following steps


./configure  ---prefix=/usr/local/kannel
make
make install

4. Change to the new directory that has been created

cd /usr/local/kannel

5. All the files for kannel are now located in this directory. In order to get Kannel up and running quickly we need to create a new config file.

Refer the the user guide for all parameters available, however the following configuration file is useful for setting up a main 'bearerbox' with an 'smsbox' in which we can send messages to an SMPP carrier.
Substitute fields highlighted with you own details. Example files can also be found in the original source files.

vi kannel.conf

group = core
dlr-storage = internal
admin-port = 13000
admin-password = password
status-password = password
admin-allow-ip = ''
smsbox-port = 13001
log-level = 0
log-file = "/usr/local/kannel/logs/kannel.log"
box-allow-ip = "127.0.0.1"

group = smsbox
smsbox-id = BOX1
bearerbox-host = 127.0.0.1
sendsms-port = 13013
log-file = "usr/local/kannel/logs/smsbox.log"
log-level = 0
access-log = "usr/local/kannel/logs/access.log"

group = sendsms-user
username = user1
password = password1

group = smsc
smsc = smpp
smsc-id = SMSC1
host = 111.111.111.111
port = 12345
smsc-username = my smsc details
smsc-password = my smsc password
address-range = ""
system-type = ""
transceiver-mode = true


6. To start the gateway run the following command

/usr/local/kannel/sbin/bearerbox kannel.conf

ensure kannel.conf is replaced with the full path to you configuration file.

Start the sms box also

/usr/local/kannel/sbin/smsbox kannel.conf

8. You can view the status of the gateway by typing the following in a browser

localhost:13000/status?password=password

7. To test the functionality of the gateway, in a browser send a new sms message to the gateway using the following url:

http://localhost:13013/cgi-bin/sendsms?username=user1&password=password1&to=0123456789&from=4444&text=testmessage


 For further reference, the user guide can be found at http://www.kannel.com/userguide.shtml

9 comments:

  1. Thanks for sharing as it is an excellent post would love to read your future post
    sms gateway

    ReplyDelete
  2. I want to know how to send sms to mobile phone using SMPP . can anyone guide me.
    My email ID: yuvaraj.ramesh@a-cti.com

    ReplyDelete
  3. while starting sms box i receive following error :-

    Start the sms box also

    /usr/local/kannel/sbin/smsbox kannel.conf

    2014-05-16 07:20:30 [20185] [0] ERROR: connect failed
    2014-05-16 07:20:30 [20185] [0] ERROR: System error 111: Connection refused
    2014-05-16 07:20:30 [20185] [0] ERROR: error connecting to server `81.4.122.252' at port `13001'
    2014-05-16 07:20:30 [20185] [0] PANIC: Couldn't connect to the bearerbox.
    2014-05-16 07:20:30 [20185] [0] PANIC: /usr/local/kannel/sbin/smsbox(gw_panic+0x17b) [0x43bb3b]
    2014-05-16 07:20:30 [20185] [0] PANIC: /usr/local/kannel/sbin/smsbox(main+0xc17) [0x40ccd7]
    2014-05-16 07:20:30 [20185] [0] PANIC: /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed) [0x7fa75437176d]
    2014-05-16 07:20:30 [20185] [0] PANIC: /usr/local/kannel/sbin/smsbox() [0x40d6


    here is my kannel.conf so please advice :-

    group = core
    dlr-storage = internal
    admin-port = 13000
    admin-password = password
    status-password = password
    admin-allow-ip = ""
    smsbox-port = 13001
    log-level = 0
    log-file = "/usr/local/kannel/logs/kannel.log"
    box-allow-ip = "81.4.122.252"

    group = smsbox
    smsbox-id = BOX1
    bearerbox-host = 81.4.122.252
    sendsms-port = 13013
    log-file = "usr/local/kannel/logs/smsbox.log"
    log-level = 0
    access-log = "usr/local/kannel/logs/access.log"

    group = sendsms-user
    username = user1
    password = password1

    group = smsc
    smsc = smpp
    smsc-id = default
    host = 182.18.132.7
    port = 2775
    smsc-username = xxxx
    smsc-password = xxxx
    address-range = ""
    system-type = ""
    transceiver-mode = TRX
    interface-version=3.4

    ReplyDelete
  4. Gr8 post... I was looking for such article that can teach me about kannel basic configurations... You made my day man. :)

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. hi, when i am sending message through kannel in english alphabets then my TPS show full but during transmission of hINDI MESSAGES my tPS remains one third of full TPS only. can anyone help me??

    thanks in advance

    ReplyDelete
  7. Hi,

    I am not able to access http://127.0.0.1:13000/status?password=bar from my browser.

    I am able to use lynx for the same, does the below implies that I have a successful configuration setup?



    root@smsc:/tmp# sudo lynx -dump "http://localhost:13000/status?password=bar"
    Kannel bearerbox version `1.4.3'. Build `Jun 9 2012 18:12:38', compiler
    `4.7.0'. System Linux, release 3.16.0-4-amd64, version #1 SMP Debian
    3.16.7-ckt25-2+deb8u2 (2016-06-25), machine x86_64. Hostname
    smsc.c.smsc-1365.internal, IP 10.140.0.2. Libxml version 2.8.0. Using
    OpenSSL 1.0.1c 10 May 2012. Compiled with MySQL 5.5.24, using MySQL
    5.5.49. Using SQLite 3.7.12.1. Using native malloc.

    Status: running, uptime 0d 0h 0m 43s

    WDP: received 0 (0 queued), sent 0 (0 queued)

    SMS: received 0 (0 queued), sent 0 (0 queued), store size -1

    SMS: inbound (0.00,0.00,0.00) msg/sec, outbound (0.00,0.00,0.00)
    msg/sec

    DLR: 0 queued, using internal storage

    Box connections:
    smsbox:(none), IP 127.0.0.1 (0 queued), (on-line 0d 0h 0m 42s)

    SMSC connections:
    FAKE FAKE:13131 (connecting, rcvd 0, sent 0, failed 0, queued 0
    msgs)

    ReplyDelete
  8. this is problem
    how to solved..

    [root@localhost gateway-1.4.3]# make
    make: *** No targets specified and no makefile found. Stop.

    ReplyDelete
  9. Support, am trying to setup my sms gateway but it seems the instruction on sending is clear.
    is there a way i can allow the receiver of the sms to reply back to it…then am able to view the replied msg in kannel?

    ReplyDelete