How to install Kannel in Centos 7?
Introduction
This article is to give an overview to install Kannel as SMS gateway with MySQL Support.Description
In this article, we are installing latest Kannel version 1.4.4 in Centos 7.Methodology
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 |
Step # 1
Download and extract FreeSWITCH source:$ cd /usr/local/src/ $ sudo wget http: //www .kannel.org /download/1 .4.4 /gateway-1 .4.4. tar .gz $ 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 = "*.*.*.*" # SMSC CONNECTIONS # 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 enquire-link-interval=30 reconnect-delay=10 interface-version=34 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:
#!/bin/sh # 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. BOXPATH= /etc/kannel/sbin PIDFILES= /etc/kannel/run CONFDIR= /etc/kannel CONF=$CONFDIR /kannel .conf USER=kannel VERSION= "" #VERSION="-0.12.4" RB=$BOXPATH /run_kannel_box $VERSION BB=$BOXPATH /bearerbox $VERSION WB=$BOXPATH /wapbox $VERSION SB=$BOXPATH /smsbox $VERSION SSD=$BOXPATH /start-stop-daemon $VERSION PATH=$BOXPATH:$PATH # 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 start) echo -n "Starting WAP gateway: bearerbox" $SSD --start --quiet --pidfile $PIDFILES /kannel_bearerbox .pid -- exec $RB -- --pidfile $PIDFILES /kannel_bearerbox .pid $BB -- $CONF echo -n " smsbox" $SSD --start --quiet --pidfile $PIDFILES /kannel_smsbox .pid -- exec $RB -- --pidfile $PIDFILES /kannel_smsbox .pid $SB -- $CONF echo "." ;; stop) echo -n "Stopping WAP gateway: " echo -n " smsbox" $SSD --stop --quiet --pidfile $PIDFILES /kannel_smsbox .pid -- exec $RB echo -n " bearerbox" $SSD --stop --quiet --pidfile $PIDFILES /kannel_bearerbox .pid -- exec $RB echo "." ;; status) 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 ;; reload) # We don't have support for this yet. exit 1 ;; restart|force-reload) $0 stop sleep 1 $0 start ;; *) echo "Usage: $0 {start|stop|status|reload|restart|force-reload}" exit 1 esac 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/kannel_bearerbox .pid /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/kannel_smsbox .pid /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 0.0.0.0:14013 0.0.0.0:* LISTEN 15412 /smsbox tcp 0 0 0.0.0.0:14000 0.0.0.0:* LISTEN 2235 /bearerbox tcp 0 0 0.0.0.0:14004 0.0.0.0:* LISTEN 2235 /bearerbox |
Now Kannel v1.4.4 has been successfully installed in Centos 7.
Step # 8
Check Kannel statusFollowing is the URL to send SMS via Kannel:
$ curl 'http://X.X.X.X:14013/cgi-bin/sendsms?smsc=SMSC01&username=<username-for-sending-sms>password=<password-for-sending-sms>&to=XXXXXXXX&from=XXXXXXX&text=testmessage&dlr-mask=31' |
thanks, you have been great help
ReplyDeleteI think only one printing mistake is there in kannel.conf
ReplyDeleteInstead 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
This comment has been removed by the author.
DeleteSame 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.
DeleteStatus is showing OK in curl command.
ReplyDeleteBut while sending SMS it shows, connection refused.
Please Help.
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:
Deletenetstat -nlp | grep box
Sorry its
Deletenetstat -pln | grep box
In the post you are stating that you are installing kennel with mysql support but instead you are compiling it without mysql support.
ReplyDeleteThis line
./configure --prefix=/etc/kannel --enable-start-stop-daemon
./configure --prefix=/etc/kannel --enable-start-stop-daemon --with-mysql
Thanks for the correction
Delete*
ReplyDeleteThis 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.
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.
ReplyDelete
ReplyDeleteHello
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
Hi guys i want to ask question how to connect coz
ReplyDeleteill 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.
change 14000, 15000 there is port issue to be handled
DeleteHi all run this command
ReplyDeletecurl 'http://localhost:13000/status?password=*****'
and result is
Denied
Hello,when i was restarting the kannel service it ws throwing error as :
ReplyDeleteStarting 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?
"sudo make" giving below error:
ReplyDeletesudo 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
y.tab.c:350:5: 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
^
y.tab.c:1510:1: 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
Help
Deletecurl 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
root@vps-206622.smartmo.xyz [test]# Authorization failed for sendsms
[1]- Done curl http://localhost:13013/cgi-bin/sendsms?username=tester
[4]+ Done to=2121
try this works for me
Deletehttp://howtolinuxadmin.blogspot.com/2016/06/sms-server-using-centos-kannel-and.html
Hello friends need help.
ReplyDeleteSMS PID need to pass for Net Core SMS Vendor, where can i add my PID numner bcz my sms are getting undeliver & rejected.