本文档介绍如何将开源解决方案(Postfix、Maildrop、Kannel)与思科身份服务引擎(ISE)集成,以便向具有访客帐户的用户传送短信服务(SMS)消息。
Cisco 建议您了解以下主题:
本文档中的信息基于以下软件和硬件版本:
本文档中的信息都是基于特定实验室环境中的设备编写的。本文档中使用的所有设备最初均采用原始(默认)配置。如果您使用的是真实网络,请确保您已经了解所有命令的潜在影响。
ISE允许您为临时网络访问创建访客帐户,通常用于访客、访客、承包商、顾问和客户。此类帐户由发起人用户通过发起人门户创建。创建帐户时,可以将动态生成的访问密码和SMS直接发送到访客用户移动电话。
思科ISE能够使用简单邮件传输协议(SMTP)通过邮件将这些凭证发送到Mail2SMS网关。此网关负责SMS传送。
市场上有多种Mail2SMS网关解决方案。它们通常可以使用不同的协议接收数据,例如SMTP、Short Message Peer-to-Peer (SMPP)、FTP、HTTP(简单对象访问协议[SOAP]、Web服务),并将SMS消息发送到特定移动电话。
最好构建您自己的SMS网关。它允许:
混合部署可能值得使用-个人SMS网关也集成了外部服务。
流程如下:
此解决方案的每个模块(Postfix、Kannel smsbox和Kannel bearebox)都可以安装在单独的服务器上。为简单起见,本例中是在同一台服务器上进行配置。
完成以下步骤以配置ISE。
Postfix是从ISE接收邮件的SMTP服务器。除少量细微更改外,使用默认配置。完成以下步骤以对其进行配置。
myhostname = smtp.test-cisco.com
mydomain = test-cisco.com
mydestination = $myhostname, $mydomain, localhost
local_transport = maildrop
maildrop unix - n n - - pipe
flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${user}
neptun ~ # useradd sms
neptun ~ # passwd sms
New password:
BAD PASSWORD: it is too simplistic/systematic
Retype new password:
passwd: password updated successfully
neptun ~ # chown -R sms:sms /home/sms/
现在,所有电邮都应正确传送给SMS用户。首次收到邮件时,会自动创建maildir结构。
在发送之前,maildrop会在用户的主目录中搜索.mailfilter。如果找到该文件,则执行脚本。文件的权限应仅限于用户:
neptun sms # touch /home/sms/.mailfilter
neptun sms # chmod go-rwx /home/sms/.mailfilter
以下是文件的内容:
# Mailfilter script for parsing ISE SMS messages
# Author: Michal Garcarz at cisco.com
# Date: 1 Dec 2013
#DEFAULT="$HOME/.maildir/"
DATE=`date`
SHELL="/bin/bash"
# Our log file
logfile "/home/sms/maildrop.log"
# Our verbosity in the log file
VERBOSE="5"
log "-------------SMS MAILFILTER LOG-----------"
log "Email received at: $DATE"
if (/^Subject:.*Guest.*Text.*Notification.*/)
{
log "Email processed by script sending SMS via Kannel"
USERNAME=""
PASSWORD=""
TO=""
if (/^text:Username:(.*)/:b)
{
log "Username exists $MATCH1"
USERNAME=$MATCH1
}
if (/^text:Password:(.*)/:b)
{
log "Password exists $MATCH1"
PASSWORD=$MATCH1
}
if (/^to:(.*)/:b)
{
log "Mobile phone exists $MATCH1"
TO=$MATCH1
}
if ($USERNAME ne "" && $PASSWORD ne "" && $TO ne "")
{
log "Sending via HTTP to kannel username=$USERNAME password=$PASSWORD to=$TO"
DATA="ISE Guest portal Username: $USERNAME Password: $PASSWORD"
#also curl can be used instead of wget
xfilter "wget -O/dev/null \"http://192.168.112.100:13013/cgi-bin/sendsms?username=
tester&password=foobar&to=$TO&text=$DATA\" >> /tmp/maildrop-kannel.log 2>>
/tmp/maildrop-kannel.log"
}
#deliver to maildir (not used since xfilter returns !=0)
to $DEFAULT/
}
脚本:
此处有两个日志文件:
可以从单个文件配置smsbox和bearebox。此配置使用外部SMPP服务器进行传输。如果您搜索smpp sms服务提供商短语,则很容易在Web上找到多个服务。配置很简单,因为无需接收和路由SMS消息。此解决方案仅用于发送并使用一个SMPP提供商。
以下内容摘自/etc/kannel/kannel.conf:
#bearerbox
group = core
admin-port = 13000
admin-password = bar
smsbox-port = 13001
log-level = 0
log-file = "/var/log/kannel/kannel.log"
access-log = "/var/log/kannel/access.log"
# SMSC SMPP
group = smsc
smsc = smpp
host = ****.com
port = 1775
smsc-username = 4ljt7wi3
smsc-password = ******
system-type =
address-range =
# SMSBOX SETUP
group = smsbox
bearerbox-host = localhost
sendsms-port = 13013
sendsms-chars = "0123456789 +-"
global-sender = 12345
log-file = "/var/log/kannel/smsbox.log"
log-level = 0
access-log = "/var/log/kannel/access.log"
white-list =
black-list =
reply-couldnotfetch =
reply-couldnotrepresent =
reply-requestfailed =
reply-emptymessage =
# SEND-SMS USERS, this credentials has been used in wget script
group = sendsms-user
username = tester
password = foobar
user-deny-ip = "*.*.*.*"
user-allow-ip = "192.168.*.*"
# SMS SERVICE Default
# there should be default always (this is for receiving SMS messages - not used)
group = sms-service
keyword = default
text = "No service specified"
可以通过USB连接移动电话并配置GSM SMSC:
group = smsc
smsc = at #type = GSM
smsc-id = usb0-modem
my-number = 1234
modemtype = auto #types: wavecom, siemens, siemens-tc35, falcom,
nokiaphone, ericsson
device = /dev/ttyUSB0 #phone device seen on server
在大多数电话上,还需要激活调制解调器功能;例如,在Android版本2.2及更高版本中,在Settings/Tethering和Portable Hotspot/USB tethering中启用该功能。
请记住同时运行bearebox和smsbox。例如:
neptun ~ # /etc/init.d/kannel-bearerbox start
* Starting kannel bearerbox ... [ ok ]
neptun ~ # /etc/init.d/kannel-smsbox start
* Starting kannel smsbox ... [ ok ]
neptun ~ # netstat -atcpn
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:13013 0.0.0.0:* LISTEN 24170/smsbox
tcp 0 0 0.0.0.0:13000 0.0.0.0:* LISTEN 24151/bearerbox
tcp 0 0 0.0.0.0:13001 0.0.0.0:* LISTEN 24151/bearerbox
Bearerbox必须至少配置一个SMSC才能启动。
使用本部分可确认配置能否正常运行。
使用发起人门户的默认端口(8443)。保证人登录https://ise.test-cisco.com:8443/sponsorportal/。
请确保在我的设置中向发起人分配了电子邮件地址:
使用SMS通知创建访客帐户:
您收到已成功创建访客帐户的确认:
ISE应发送邮件至已配置的SMTP服务器。
SMTP服务器收到邮件并使用邮件丢弃将其传送到本地帐户(sms@test-cisco.com)。以下内容摘自/var/log/messages:
Nov 30 22:39:47 neptun postfix/smtpd[18460]: connect from unknown[192.168.112.1]
Nov 30 22:39:47 neptun postfix/smtpd[18460]: 2B36030B32: client=unknown
[192.168.112.1]
Nov 30 22:39:47 neptun postfix/cleanup[18463]: 2B36030B32: message-id=
<563762958.941385847586377.JavaMail.root@ise2>
Nov 30 22:39:47 neptun postfix/qmgr[32658]: 2B36030B32: from=,
size=689, nrcpt=1 (queue active)
Nov 30 22:39:47 neptun postfix/pipe[18464]: 2B36030B32: to=<sms@test-cisco.com>,
relay=maildrop, delay=0.18, delays=0.14/0/0/0.04, dsn=2.0.0, status=sent (delivered
via maildrop service)
在发送电子邮件到SMS之前,maildir目录会执行/home/sms/.mailfilter,后者会执行特定操作。
以下内容摘自/home/sms/maildrop.log:
-------------SMS MAILFILTER LOG-----------
Email received at: Sat Nov 30 22:39:47 CET 2013
Email processed by script sending SMS via Kannel
Username exists jsmith02
Password exists t6ub79_6r
Mobile phone exists 4850xxxxxxx
Sending via HTTP to kannel username= jsmith02 password= t6ub79_6r to=4850xxxxxxx
mailfilter脚本读取所有数据并执行xfilter,后者调用wget以将所有参数传递给Kannel。
以下内容摘自/tmp/maildrop-kannel.log:
--2013-11-30 22:39:47-- http://192.168.112.100:13013/cgi-bin/sendsms?username=
tester&password=foobar&to=4850xxxxxxx&text=ISE%20Guest%20portal%20Username:
%20%20jsmith02%20Password:%20%20t6ub79_6r
Connecting to 192.168.112.100:13013... connected.
HTTP request sent, awaiting response... 202 Accepted
Length: 24 [text/html]
Saving to: `/dev/null'
0K 100% 1.14M=0s
2013-11-30 22:39:47 (1.14 MB/s) - `/dev/null' saved [24/24]
HTTP GET请求已接受。
“Kannel smsbox”报告其收到来自wget的HTTP请求,并已将该请求发送到收件箱以便传送SMS。
以下内容摘自/var/log/kannel/smsbox.log:
2013-11-30 22:39:47 [18184] [5] INFO: smsbox: Got HTTP request </cgi-bin/sendsms>
from <192.168.112.100>
2013-11-30 22:39:47 [18184] [5] INFO: sendsms used by
2013-11-30 22:39:47 [18184] [5] INFO: sendsms sender:<tester:12345>
(192.168.112.100) to:<4850xxxxxxx> msg:jsmith02 Password: t6ub79_6r>
2013-11-30 22:39:47 [18184] [5] DEBUG: Stored UUID fd508632-9408-49e1-9eda-
3ce8d4b939d4
2013-11-30 22:39:47 [18184] [5] DEBUG: message length 57, sending 1 messages
2013-11-30 22:39:47 [18184] [5] DEBUG: Status: 202 Answer: <Sent.>
2013-11-30 22:39:47 [18184] [5] DEBUG: Delayed reply - wait for bearerbox
2013-11-30 22:39:47 [18184] [0] DEBUG: Got ACK (0) of fd508632-9408-49e1-9eda-
3ce8d4b939d4
Kannel速递箱连接到远程SMPP服务器并成功发送消息。
以下内容摘自/var/log/kannel/kannel.log:
2013-11-30 22:39:47 [18165] [8] DEBUG: boxc_receiver: sms received
2013-11-30 22:39:47 [18165] [8] DEBUG: send_msg: sending msg to box: <127.0.0.1>
2013-11-30 22:39:47 [18165] [6] DEBUG: SMPP[SMPP:*****.com:1775/0:4ljt7wi3:]:
throughput (0.00,0.00)
2013-11-30 22:39:47 [18165] [6] DEBUG: SMPP[SMPP:*****.com:1775/0:4ljt7wi3:]:
Sending PDU:
2013-11-30 22:39:47 [18165] [6] DEBUG: SMPP PDU 0x2056bf0 dump:
2013-11-30 22:39:47 [18165] [6] DEBUG: type_name: submit_sm
2013-11-30 22:39:47 [18165] [6] DEBUG: command_id: 4 = 0x00000004
2013-11-30 22:39:47 [18165] [6] DEBUG: command_status: 0 = 0x00000000
2013-11-30 22:39:47 [18165] [6] DEBUG: sequence_number: 5 = 0x00000005
2013-11-30 22:39:47 [18165] [6] DEBUG: service_type: NULL
2013-11-30 22:39:47 [18165] [6] DEBUG: source_addr_ton: 2 = 0x00000002
2013-11-30 22:39:47 [18165] [6] DEBUG: source_addr_npi: 1 = 0x00000001
2013-11-30 22:39:47 [18165] [6] DEBUG: source_addr: "12345"
2013-11-30 22:39:47 [18165] [6] DEBUG: dest_addr_ton: 2 = 0x00000002
2013-11-30 22:39:47 [18165] [6] DEBUG: dest_addr_npi: 1 = 0x00000001
2013-11-30 22:39:47 [18165] [6] DEBUG: destination_addr: "4850xxxxxxx"
2013-11-30 22:39:47 [18165] [6] DEBUG: esm_class: 3 = 0x00000003
2013-11-30 22:39:47 [18165] [6] DEBUG: protocol_id: 0 = 0x00000000
2013-11-30 22:39:47 [18165] [6] DEBUG: priority_flag: 0 = 0x00000000
2013-11-30 22:39:47 [18165] [6] DEBUG: schedule_delivery_time: NULL
2013-11-30 22:39:47 [18165] [6] DEBUG: validity_period: NULL
2013-11-30 22:39:47 [18165] [6] DEBUG: registered_delivery: 0 = 0x00000000
2013-11-30 22:39:47 [18165] [6] DEBUG: replace_if_present_flag: 0 = 0x00000000
2013-11-30 22:39:47 [18165] [6] DEBUG: data_coding: 0 = 0x00000000
2013-11-30 22:39:47 [18165] [6] DEBUG: sm_default_msg_id: 0 = 0x00000000
2013-11-30 22:39:47 [18165] [6] DEBUG: sm_length: 57 = 0x00000039
2013-11-30 22:39:47 [18165] [6] DEBUG: short_message:
2013-11-30 22:39:47 [18165] [6] DEBUG: Octet string at 0x205ec70:
2013-11-30 22:39:47 [18165] [6] DEBUG: len: 57
2013-11-30 22:39:47 [18165] [6] DEBUG: size: 58
2013-11-30 22:39:47 [18165] [6] DEBUG: immutable: 0
2013-11-30 22:39:47 [18165] [6] DEBUG: data: 49 53 45 20 47 75 65 73
74 20 70 6f 72 74 61 6c ISE Guest portal
2013-11-30 22:39:47 [18165] [6] DEBUG: data: 20 55 73 65 72 6e 61 6d
65 3a 20 20 6a 73 6d 69 Username: jsmi
2013-11-30 22:39:47 [18165] [6] DEBUG: data: 74 68 30 32 20 50 61 73
73 77 6f 72 64 3a 20 20 th02 Password:
2013-11-30 22:39:47 [18165] [6] DEBUG: data: 74 36 75 62 37 39 11 36
72 t6ub79.6r
2013-11-30 22:39:47 [18165] [6] DEBUG: Octet string dump ends.
2013-11-30 22:39:47 [18165] [6] DEBUG: SMPP PDU dump ends.
2013-11-30 22:39:47 [18165] [6] DEBUG: SMPP[SMPP:******.com:1775/0:4ljt7wi3:]:
throughput (1.00,0.00)
2013-11-30 22:39:47 [18165] [6] DEBUG: SMPP[SMPP:******.com:1775/0:4ljt7wi3:]:
throughput (1.00,0.00)
2013-11-30 22:39:47 [18165] [6] DEBUG: SMPP[SMPP:******.com:1775/0:4ljt7wi3:]:
Got PDU:
2013-11-30 22:39:47 [18165] [6] DEBUG: SMPP PDU 0x2056bf0 dump:
2013-11-30 22:39:47 [18165] [6] DEBUG: type_name: submit_sm_resp
2013-11-30 22:39:47 [18165] [6] DEBUG: command_id: 2147483652 = 0x80000004
2013-11-30 22:39:47 [18165] [6] DEBUG: command_status: 0 = 0x00000000
2013-11-30 22:39:47 [18165] [6] DEBUG: sequence_number: 5 = 0x00000005
2013-11-30 22:39:47 [18165] [6] DEBUG: message_id: "4128473611307259"
2013-11-30 22:39:47 [18165] [6] DEBUG: SMPP PDU dump ends.
2013-11-30 22:39:47 [18165] [6] DEBUG: SMPP[SMPP:******.com:1775/0:4ljt7wi3:]:
throughput (1.00,0.00)
请注意,源地址设置为12345。此设置不重要。外部SMPP服务器重写该值。可以购买其他服务来以不同的方式呈现。
访客用户收到SMS:
本部分提供了可用于对配置进行故障排除的信息。
当您创建访客帐户时,可能会遇到此错误:无法向以下访客用户发送文本消息:xxxx。 您必须将电子邮件地址添加到设置页面。如果您收到该错误消息,请验证发起人邮件地址。
版本 | 发布日期 | 备注 |
---|---|---|
1.0 |
04-Dec-2013 |
初始版本 |