Quickstart With Kannel

August 24, 2023

Recently , I got opportunity to work in a project whose main aim is to develop a system that could send and receive SMS via Kannel. During the course of building the system, I learned more about it and I am here to share my knowledge on basics of Kannel and its configuration to make a simple system which could send and receive SMS. Kannel is a compact and very powerful open source WAP and SMS gateway, used widely across the globe both for serving trillions of short messages (SMS), WAP Push service indications and mobile internet connectivity. In this article , I would focus only on SMS configuration part in Kannel. SMS, Short Messaging Service, is a way to send short (160 character) messages from one GSM phone to another. When a sender sends the SMS to certain number , this sms is send to SMS center ( SMSC ) first which is responsible for that number. This SMS center then sends the message onward to specified receiver. The SMS center might be any of the mobile network operator like NTC , NCELL , UTL etc. for Nepal or Docomo , Vodafone for India. Here , in this article I have used a FAKE SMSC program which acts as a SMSC simulator. Since we dont have real SMSC available here so I will be using a Fake SMSC for test . REQUIREMENTS: To make a system working we require : Kannel FAKE SMSC

sudo apt-get install kannel sudo apt-get install kannel-extras Configuring the SMS gateway : The configuration file must be set at /etc/kannel/kannel.conf . The configuration part can be divided into three parts : Bearerbox configurations Smsbox configurations Wapbox configurations

We would only be talking about the Bearerbox and Smsbox configuration here. BEARERBOX CONFIGURATIONS: group = core admin-port = 13000 admin-password = test admin-deny-ip = "..." admin-allow-ip = "127.0.0.1" smsbox-port = 13001 box-deny-ip = "..." box-allow-ip = "127.0.0.1" dlr-storage = internal log-level = 0 SMSBOX CONFIGURATIONS: group = smsbox smsbox-id = mysmsbox bearerbox-host = localhost sendsms-port = 13013 log-level = 0 Further we have to define the Sms-service ,Sendsms-user , Smsbox-route and SMSC to make system send SMS. group = sendsms-user username = simple password = simple123 group = smsc smsc = fake smsc-id = FAKE port = 10000 log-level = 0 group = smsbox-route smsbox-id = mysmsbox smsc-id = FAKE group = sms-service keyword = default text = "hi how are you" Inside the /etc/kannel/kannel.conf the configuration file looks like : kannel.confThe above part is the configuration part for kannel.conf inside /etc/kannel. After writing the configuration we would start the kannel service using . sudo service kannel start This will start the Bearerbox. Similarly we have to start the Smsbox . For that we can follow the following steps : cd /etc/kannel smsbox We are using FAKE SMSC to send and receive message. Message can be send in two ways from the system and they are : Inbound Message Outbound Message

Inbound Message : Inbound message are those messages that are received in the kannel system with specific keyword and the kannel system will reply back with the text associated with that keyword. In the real life scenario this can be related to any customer sending message for request of news report , weather report or SLC result using certain keyword like SLC , sending it to some short code number like 5234 and getting result like "congratulation you have passed". Let us send the inbound message using FAKE SMSC. We will send a message to kannel with keyword hello and the system will reply back with the message hi how are you. cd /var/lib/kannel/test ./fakesmsc -m 1 "123 789 text hello " We can see the received message in the last line of the log in above picture as hi how are you . Similarly , we can also check the status in the browser using : http://localhost:13000/status ?password = test Outbound Message : Kannel can be used to send outbound messages . Outbound message are those messages which are sent by the system directly to large number of customers who are subscribed for the particular services . Suppose imagine a scenario where the customer has subscribed for particular services like News with NTC operator . Then the NTC operator will send an outbound message with the service requested i.e in this case it sends the current National news to the customer . let us send an outbound message from kannel . For that we would first run the FAKE SMSC . cd /usr/lib/kannel/test ./fakesmsc In the next terminal we will send an outbound message. Using FAKE SMSC we can send the outbound message hello by using the following command in the terminal: curl "http://localhost:13013/cgi-bin/sendsms?username=simple&password=simple123&from=100&to=2121&text=hello" In the above figure we can see 0:Accepted for delivery which means the FAKE SMSC is receiving the sms and would be sent to sender . Now we can see in the last line of the log information the message hello has been received. Again , we can check the status in the browser using : http://localhost:13000/status ?password = test That is everything you need to get Kannel up , running and operational. The complete kannel configuration file is given below :

kannel.conf


Profile picture

Written by Sudeep Parajuli who lives and works in Nepal building useful things. You should follow them on Twitter