Skip to content

Cisco ルータやスイッチで EEM を使う

Cisco ルータやスイッチでは EEM (Embedded Event Manager) 機能を使うことで「標準機能だけでは解決し辛い (または解決出来ない) 問題を解決する」ことが出来るようになります。 今回はシンプルな例として「あるインターフェイスが LinkDown/Up したら、別のインターフェイスを shutdown / no shutdown する」というケースの設定例をメモしておきます。 検証は CML2 上の以下で実施しました。

OS プラットフォーム バージョン
IOS IOSv 15.9(3)M3
IOS-XE Catalyst 8000v 17.06.02

IOS での設定例

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
track 1 interface GigabitEthernet0/0 line-protocol
!
event manager applet SHUTDOWN-Gi1
event track 1 state down
action 1.0 cli command "enable"
action 2.0 cli command "configure terminal"
action 3.0 cli command "interface GigabitEthernet0/1"
action 4.0 cli command "shutdown"
action 5.0 cli command "end"
!
event manager applet NO-SHUTDOWN-Gi1
event track 1 state up
action 1.0 cli command "enable"
action 2.0 cli command "configure terminal"
action 3.0 cli command "interface GigabitEthernet0/1"
action 4.0 cli command "no shutdown"
action 5.0 cli command "end"
!
end

Gi0/0 LinkDown 時の例

Gi0/0 が LinkDown すると EEM の「SHUTDOWN-Gi1」アプレットが実行され、Gi0/1 が shutdown されたことが分かります。

1
2
3
4
5
6
*Mar  6 01:29:35.739: %TRACK-6-STATE: 1 interface Gi0/0 line-protocol Up -> Down
*Mar  6 01:29:35.859: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to down
*Mar  6 01:29:36.032: %SYS-5-CONFIG_I: Configured from console by  on vty0 (EEM:SHUTDOWN-Gi1)
*Mar  6 01:29:36.859: %LINK-3-UPDOWN: Interface GigabitEthernet0/0, changed state to down
*Mar  6 01:29:37.998: %LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to administratively down
*Mar  6 01:29:38.998: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to down

Gi0/0 LinkUp 時の例

Gi0/0 が LinkUp すると EEM の「NO-SHUTDOWN-Gi1」アプレットが実行され、Gi0/1 が no shutdown されたことが分かります。

1
2
3
4
5
6
*Mar  6 01:29:49.739: %TRACK-6-STATE: 1 interface Gi0/0 line-protocol Down -> Up
*Mar  6 01:29:50.148: %SYS-5-CONFIG_I: Configured from console by  on vty0 (EEM:NO-SHUTDOWN-Gi1)
*Mar  6 01:29:50.861: %LINK-3-UPDOWN: Interface GigabitEthernet0/0, changed state to up
*Mar  6 01:29:51.861: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up
*Mar  6 01:29:51.996: %LINK-3-UPDOWN: Interface GigabitEthernet0/1, changed state to up
*Mar  6 01:29:52.996: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to up

IOS-XE での設定例

IOS-XE (Catalyst 8000v) でも同じ設定が可能でした。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
track 1 interface GigabitEthernet1 line-protocol
!
event manager applet SHUTDOWN-Gi2
event track 1 state down
action 1.0 cli command "enable"
action 2.0 cli command "configure terminal"
action 3.0 cli command "interface GigabitEthernet2"
action 4.0 cli command "shutdown"
action 5.0 cli command "end"
!
event manager applet NO-SHUTDOWN-Gi2
event track 1 state up
action 1.0 cli command "enable"
action 2.0 cli command "configure terminal"
action 3.0 cli command "interface GigabitEthernet2"
action 4.0 cli command "no shutdown"
action 5.0 cli command "end"
!
end

Gi1 LinkDown 時の例

Gi1 が LinkDown すると EEM の「SHUTDOWN-Gi2」アプレットが実行され、Gi2 が shutdown されたことが分かります。

1
2
3
4
5
6
*Mar  6 01:37:12.890: %TRACK-6-STATE: 1 interface Gi1 line-protocol Up -> Down
*Mar  6 01:37:13.445: %SYS-5-CONFIG_I: Configured from console by  on vty0 (EEM:SHUTDOWN-Gi2)
*Mar  6 01:37:14.531: %LINK-3-UPDOWN: Interface GigabitEthernet1, changed state to down
*Mar  6 01:37:15.346: %LINK-5-CHANGED: Interface GigabitEthernet2, changed state to administratively down
*Mar  6 01:37:15.531: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1, changed state to down
*Mar  6 01:37:16.346: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet2, changed state to down

Gi1 LinkUp 時の例

Gi1 が LinkUp すると EEM の「NO-SHUTDOWN-Gi2」アプレットが実行され、Gi2 が no shutdown されたことが分かります。

1
2
3
4
5
6
*Mar  6 01:37:32.896: %TRACK-6-STATE: 1 interface Gi1 line-protocol Down -> Up
*Mar  6 01:37:33.346: %SYS-5-CONFIG_I: Configured from console by  on vty0 (EEM:NO-SHUTDOWN-Gi2)
*Mar  6 01:37:34.531: %LINK-3-UPDOWN: Interface GigabitEthernet1, changed state to up
*Mar  6 01:37:35.531: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1, changed state to up
*Mar  6 01:37:44.532: %LINK-3-UPDOWN: Interface GigabitEthernet2, changed state to up
*Mar  6 01:37:45.533: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet2, changed state to up