LoginSignup
17
9

More than 5 years have passed since last update.

Cisco 1100 LTE のSMS と IOS-XE EEMで遊ぶ

Last updated at Posted at 2018-07-27

これは何?

Cisco 1100シリーズという小さいけどイケてるルータがコッソリと(?)販売されていますが、これはIOS-XEというOSで動くシスコの小規模拠点向けルータだそうです。

今回、親切なお兄様からC1111-4PLTELAというLTE型番をお借りできました。私は、LTEやら携帯やらは初心者なのですが、EEMはわりと得意なのでそっち系の相談は(今でも)ときどき頂いていまして、特に「LTE経由でルータをあんなことやこんなことができるのでは?」というのが、話題に上りつつも持ってないので確認できずにいました。今回、実際にいくつか動作確認できたので、忘れないように残しておきたいと思います。自分用のメモです。

※参考

わがラボにやってきたCisco 1111 LTE。SIMが挿さってます。
IMG_3975.jpg

環境と準備

IOS-XEバージョン

C1111LTE#sho ver | i .bin
System image file is "bootflash:c1100-universalk9_ias.16.08.01.SPA.bin"

SIMインストールと確認

SIMを入れます。

C1111LTE#show controllers cellular 0/2/0 | i SIM
Cellular Dual SIM details:
SIM 0 is not present
SIM 1 is present
SIM 1 is active SIM

SIMが正しく認識されたら、StatusがOKになります。

C1111LTE#sho cell 0/2/0 security 
Active SIM = 1
SIM switchover attempts = 0
Card Holder Verification (CHV1) = Disabled
SIM Status = OK
SIM User Operation Required = None
Number of CHV1 Retries remaining = 1

もしOKにならない場合、モデム再起動を試します。

C1111LTE#test cellular 0/2/0 modem-power-cycle

確認していきます。

C1111LTE#show cellular 0/2/0 firmware 
 Idx Carrier      FwVersion    PriVersion   Status  
 1   DOCOMO       02.20.03.00  001.001_000  Active  
 2   GENERIC      02.20.03.00  002.017_001  Inactive
 3   KDDI         02.20.03.00  000.008_000  Inactive
 4   Softbank     02.20.03.00  000.007_000  Inactive
 5   TELSTRA      02.20.03.01  002.019_001  Inactive

Firmware Activation mode  =  AUTO

電話番号やIMEIなどが確認でき、SIMが認識されています。

C1111LTE#show cellular 0/2/0 hardware 
Modem Firmware Version = SWI9X30C_02.20.03.00
Device Model ID =  EM7430
International Mobile Subscriber Identity (IMSI) = 440103077108336
International Mobile Equipment Identity (IMEI) = 35581307007****
Integrated Circuit Card ID (ICCID) = 8981100023409899741
Mobile Subscriber Integrated Services
Digital Network-Number (MSISDN) = 0801298****
Factory Serial Number (FSN) = LR720608660210
Modem Status = Modem Online
Current Modem Temperature = 29 deg C
PRI SKU ID = 1102682, PRI version = 001.001_000, Carrier = DOCOMO
OEM PRI version = 000.007

Docomoに繋がっていることがわかります。

C1111LTE#show cellular 0/2/0 network 
Current System Time = Fri Jul 27 9:12:5 2018
Current Service Status = Normal
Current Service = Packet switched
Current Roaming Status = Home
Network Selection Mode = Automatic
Network = JP DOCOMO
Mobile Country Code (MCC) = 440
Mobile Network Code (MNC) = 10
Packet switch domain(PS) state = Attached
LTE Carrier Aggregation state = Deconfigured
Registration state(EMM) = Registered
EMM Sub State = Normal Service
Tracking Area Code (TAC) = 5221
Cell ID = 34633987
Negotiated network MTU is 1500

ラジオの状態がわかります。

C1111LTE#sho cellular 0/2/0 radio
Radio power mode = online
LTE Rx Channel Number =  276
LTE Tx Channel Number =  65535
LTE Band =  1
LTE Bandwidth = 15 MHz
Current RSSI = -34 dBm
Current RSRP = -63 dBm
Current RSRQ = -9 dB
Current SNR = 30.0  dB
Physical Cell Id = 46
Number of nearby cells = 1
Idx      PCI (Physical Cell Id)
--------------------------------
1              46
Radio Access Technology(RAT) Preference = AUTO
Radio Access Technology(RAT) Selected = LTE

設定と確認

プロファイルを作ります。携帯で遊ぶ時のアレです。モデムに書き込まれ、IOSの設定と後でくっつけます。

C1111LTE#cellular 0/2/0 lte profile create 4 spmode.ne.jp chap spmode spmode ipv4

以下は、既にActiveになった後のログですが、通信がない状態ではINACTIVEのままが正しいです。

C1111LTE#show cellular 0/2/0 profile  

<snip>

Profile 3 = INACTIVE
--------
PDP Type = IPv4v6
Access Point Name (APN) = mopera.net
Authentication = None

Profile 4 = ACTIVE* **
--------
PDP Type = IPv4
PDP address = 10.200.128.69
Access Point Name (APN) = spmode.ne.jp
Authentication = CHAP
Username =  spmode
Password =  spmode
    Primary DNS address = 110.163.0.5
    Secondary DNS address = 110.163.0.6

<snip>

Profile 7 = INACTIVE
--------
PDP Type = IPv4
Access Point Name (APN) = dmm.com
Authentication = PAP or CHAP
Username =  dmm@dmm.com
Password =  dmm

  * - Default profile 
 ** - LTE attach profile

こんな感じで、Cellular 0/2/0に先のプロファイルを充てます。data-profileもattach-profileも同じでOKです。

C1111LTE(config)#controller Cellular 0/2/0 
C1111LTE(config-controller)#?
Controller configuration commands:
  default      Set a command to its defaults
  description  Controller specific description
  exit         Exit from controller configuration mode
  help         Description of the interactive help system
  lte          LTE type carrier
  mpls         MPLS Controller Commands
  no           Negate a command or set its defaults

C1111LTE(config-controller)#lte ?
  event          cellular snmp event persistence
  failovertimer  Failover timeout value in mins
  firmware       Select firmware option
  gps            GPS configuration
  interface      Cellular interface
  modem          Modem logging configuration
  radio          Controller's radio
  sim            Subscriber Identity Module
  sms            SMS configuration

C1111LTE(config-controller)#lte sim ?
  authenticate  CHV1 authentication
  data-profile  Data Profile number
  max-retry     Maximum SIM switchovers
  primary       Controller's primary SIM

C1111LTE(config-controller)#lte sim data-profile 4 attach-profile 4 slot 1 
C1111LTE#sho run controller cellular 0/2/0
!
controller Cellular 0/2/0
 lte sim data-profile 4 attach-profile 4 slot 1
 lte modem link-recovery disable

あとはIP的な設定なので、CCIEなみなさまに頑張って欲しいところですが、私は横着なので、先人の設定を最小限にコピペしていきます。
セルラーインターフェースをNATの外側とし、ダイヤラーで発呼します。今回は試験用にLoopback0をNATの内側とします。

interface Cellular0/2/0
 ip address negotiated
 ip nat outside
 dialer in-band
 dialer idle-timeout 0
 dialer-group 10
 pulse-time 1
!
dialer-list 10 protocol ip list 10
access-list 10 permit any
interface Loopback0
 ip address 1.1.1.1 255.255.255.255
 ip nat inside
ip nat inside source list 11 interface Cellular0/2/0 overload
access-list 11 permit 1.1.1.1
!
ip route 0.0.0.0 0.0.0.0 Cellular0/2/0

最初にダイヤラーをアップさせておきます。この時点で、LTEプロファイルがはじめてActiveになり、IPアドレスやDNSサーバが割り振られ、通信できるようになります。ダイヤラーのタイムアウト設定に応じて、LTEはINACTIVEになります。私は横着なので、idle-timeout 0にしています。

C1111LTE#ping 8.8.8.8 source loopback 0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 8.8.8.8, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1 
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 36/72/160 ms
C1111LTE#sho dialer 

Ce0/2/0 - dialer type = DIALER CWAN
Idle timer (never), Fast idle timer (20 secs)
Wait for carrier (30 secs), Re-enable (15 secs)
Dialer state is data link layer up
Dial reason: ip (s=1.1.1.1, d=8.8.8.8)
Time until disconnect never
Current call connected 02:16:12
Connected to lte

Dial String      Successes   Failures    Last DNIS   Last status
lte                      1          0    02:16:12       successful   Default
<snip>

外部と通信できるようになりました。

C1111LTE#ping yahoo.co.jp source loopback 0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 182.22.59.229, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1 
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 32/48/84 ms

SMSの送受信

ルータからの送信

ルータのコマンド(手打ち)でSMSを送ってみます。

C1111LTE#cellular 0/2/0 lte sms send 0909007**** This message is sent from C1100-LTE Hoge! 
C1111LTE#
*Jul 27 09:54:14.944: %CELLWAN-2-SMS_ARCH_PATH_UNCONFIGURED: Cellular0/2/0 failed to archive SMS because 'gsm|cdma|lte sms archive path' under cellular controller is not configured.
*Jul 27 09:54:14.945: %CELLWAN-5-OUTGOING_SMS_SENT: Cellular0/2/0 has just sent an outgoing SMS successfully.

IMG_3984.jpg

ルータでの受信

携帯からSMSを送ってみます。

IMG_3985.jpg

Syslogが出ました。

*Jul 27 10:02:35.033: Cellular0/2/0: New SMS received on index 14. Please issue a view command to see it
*Jul 27 10:02:35.033: %CELLWAN-2-SMS_ARCH_PATH_UNCONFIGURED: Cellular0/2/0 failed to archive SMS because 'gsm|cdma|lte sms archive path' under cellular controller is not configured.

モデム上にメッセージが保存されており、コマンドで確認できます。

C1111LTE#cellular 0/2/0 lte sms view 14
SMS ID: 14
TIME: 18-07-27 19:02:39
FROM: 0909007****
TO: 0801298****
SIZE: 33
Hi, I am Kazumasa. You are cool!!

256個まで保存できるようです。

C1111LTE#cellular 0/2/0 lte sms view ?
  <0-255>  SMS message id, 0 - 255
  all      Display details of all SMS
  summary  Display summary of all SMS

サマリーコマンドは便利ですね。(みんな色々送ってきますw)

C1111LTE#cellular 0/2/0 lte sms view summary 
ID   FROM                  YY/MM/DD HR:MN:SC  SIZE  CONTENT
<snip>                        
9    0907717****           18-07-27 17:48:03  8     Oh yeah                     
10   0907717****           18-07-27 17:49:33  8     hogehoge                    
11   0802011****           18-07-27 18:00:09  23    wifi on sent by hsakabe     
12   0908870****           18-07-27 18:00:27  5     ^_0U^S^_                       
13   0802011****           18-07-27 18:00:54  6     sh ver                      
14   0909007****           18-07-27 19:02:39  33    Hi, I am Kazumasa. You ar...

SMSの送受信履歴は、外部のサーバに保存できるようで、私はこれを設定してないために、先ほどからSyslogで保存エラーが出てたのでした。

C1111LTE(config)#controller Cellular 0/2/0 
C1111LTE(config-controller)#lte sms ?
  archive  SMS archive configuration

C1111LTE(config-controller)#lte sms archive path ?
  ftp:    URL to directory used to archive SMS
  http:   URL to directory used to archive SMS
  https:  URL to directory used to archive SMS
  pram:   URL to directory used to archive SMS
  rcp:    URL to directory used to archive SMS
  scp:    URL to directory used to archive SMS
  tftp:   URL to directory used to archive SMS

EEMと連携

SMSを受信検知 -> アクション

最小限のやつです。

C1111LTE#sh run | be event manager
event manager applet HelloSMS
 event syslog pattern "New SMS received"
 action 100 puts "SMS received!"

ルータにSMSを送ります。
IMG_3987.jpg

EEMが動作して、Syslog検知イベントに対応して、コンソール上にカスタムメッセージが出力されました^^

C1111LTE#
*Jul 27 10:22:25.436: Cellular0/2/0: New SMS received on index 15. Please issue a view command to see it
*Jul 27 10:22:25.436: %CELLWAN-2-SMS_ARCH_PATH_UNCONFIGURED: Cellular0/2/0 failed to archive SMS because 'gsm|cdma|lte sms archive path' under cellular controller is not configured.
*Jul 27 10:22:25.439: %HA_EM-6-LOG: HelloSMS: SMS received!

ルータの内部でイベント検知 -> アクション SMS送信

ルータ内部のイベントは様々検知できるのはEEMの良いところです。今回は、ルーティングテーブルの状態遷移を検知して、「show ip route summary | i Total」の結果をSMSで通知する。という設定にしてみました。160文字に収まるやつです。

C1111LTE#cellular 0/2/0 lte sms send 0909007**** ?
  LINE  SMS text until the end of line (EOL) up to 160 characters

通常はこういうやつですね。

C1111LTE#sh ip route summary                     
IP routing table name is default (0x0)
IP routing table maximum-paths is 32
Route Source    Networks    Subnets     Replicates  Overhead    Memory (bytes)
connected       0           2           0           192         608
static          1           0           0           96          304
application     0           0           0           0           0
internal        2                                               768
Total           3           2           0           288         1680

フィルターします。ルート数の増減と、それのメモリーへの影響を、SMSで監視します(ほぼこじつけ)。

C1111LTE#sh ip route summary | i Total
Total           3           2           0           288         1680

以下がEEMの設定。イベントはあらゆるルートの遷移を捕捉してイベント発行。CLIの結果は、$_cli_resultで渡されるので、それをSMSで送信するコマンドに書いておきます。(検証環境では、意味の無いループバックを手動でshut/no shutしてイベントを発行しています。)

event manager applet SendSMS
 event routing network 0.0.0.0/0 type all protocol all
 action 090 cli command "enable"
 action 100 cli command "show ip route summary | i Total"
 action 110 puts "$_cli_result"
 action 120 cli command "cellular 0/2/0 lte sms send 0909007**** $_cli_result"

これでいつでもルート数とメモリーの監視ができます(謎)。ネットワークが落ちても、ルータ内部を調査して、SMSで通知する仕組みに応用できそうです。

IMG_3992.jpg

SMS受信検知 -> アクション SMSで応答

これのバリエーションとして、特に状態遷移がない場合でも、利用者の希望でSMSでリクエストを送り、その時のルータ内部の状態(ルーティングテーブルなど)を調査してSMSで送り返す、というのが考えられます。疲れてきたので、サンプルコンフィグは先ほどのを合体させます。

event manager applet SMStoSMS
 event syslog pattern "New SMS received"
 action 090 cli command "enable"
 action 100 cli command "show ip route summary | i Total"
 action 110 puts "$_cli_result"
 action 120 cli command "cellular 0/2/0 lte sms send 09090073826 $_cli_result"

何を送ってもルーティングテーブルを教えてくれる、意味不明なサンプルでした。

IMG_3993.jpg

まとめとその次

Cisco IOS-XEが動作するLTEモデルは、EEMが使える。
EEMと組み合わせて、SMS受信のSyslogをトリガーにIOS内部でアクションやスクリプトを発動したり、SMSを送信するコマンドを実行したりできました。結構遊べそう!

今回は、SMSのメッセージに応じて動作を振り分けるところまでやってませんが、「SyslogでSMS受信」-> 「SMSの内容を確認」-> 「EEMのアクションを分岐」といった流れも、比較的簡単に実装できそうです。ルータに送るSMSのメッセージに応じて、ルータ内部の動作をカスタムで実行したり、ルータに調査して応答させるコマンドをSMSで分けたり、トラブルシュートのパターンを操作したり、といったわりと実用的な使い方も考えられそうです。時間ができたら、やってみたいと思います!

17
9
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
17
9