本文說明如何將開源解決方案(Postfix、Maildrop、Kannel)與思科身份服務引擎(ISE)整合,以便向具有訪客帳戶的使用者提供簡訊服務(SMS)消息。
思科建議您瞭解以下主題:
本文中的資訊係根據以下軟體和硬體版本:
本文中的資訊是根據特定實驗室環境內的裝置所建立。文中使用到的所有裝置皆從已清除(預設)的組態來啟動。如果您的網路正在作用,請確保您已瞭解任何指令可能造成的影響。
ISE允許您為臨時網路訪問建立訪客帳戶,通常用於訪客、訪客、承包商、顧問和客戶。此類帳戶由發起人使用者透過發起人門戶建立。建立帳戶時,可以將動態生成的訪問密碼和SMS直接傳送到訪客使用者行動電話。
思科ISE能夠使用簡單郵件傳輸協定(SMTP)透過電子郵件將這些憑證傳送到Mail2SMS網關。此閘道負責簡訊傳遞。
市場上有多種Mail2SMS網關解決方案。它們通常可以使用不同的協定接收資料,例如SMTP、Short Message Peer-to-Peer (SMPP)、FTP、HTTP (Simple Object Access Protocol (SOAP)、Web services),然後傳送SMS消息到特定行動電話。
最好建立您自己的簡訊閘道。它允許:
混合部署可能是值得的-一種與外部服務整合的個人SMS網關。
流程如下:
此解決方案的每個模組(Postfix、Kannel smsbox和Kannel bearerbox)都可以安裝在單獨的伺服器上。為簡單起見,本示例中是在同一台伺服器上配置的。
完成以下步驟以配置ISE。
後置是SMTP伺服器,接收來自ISE的電子郵件。除了一些細微的更改外,會使用預設配置。完成以下步驟即可進行設定。
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版及更高版本中,在「設定/Tethering」和「攜帶型熱點/USB tethering」中啟用了該功能。
請記得同時執行bearerbox和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 |
初始版本 |