パナソニックMNOシリーズはSNMPトラップによる通知を備えたルータです。snmptrapを設定する事によって、リンクダウン, 設定変更, 侵入, 状態変化などをsnmptrapdサーバに通知する事ができます。
コマンド一覧
このシナリオで重要なコマンド一覧は以下の通りです。
Switch(config)# snmp-server agent Switch(config)# snmp-server host <entry_num> type [ v1 | v2 ] <addr> trap <community> Switch(config)# snmp-server enable traps fan-fail Switch(config)# snmp-server enable traps linkupdown <port_list> Switch(config)# snmp-server enable traps poe Switch(config)# snmp-server enable traps snmp authentication Switch(config)# snmp-server enable traps poe Switch(config)# snmp-server enable traps temperature-control Switch(config)# snmp-server enable traps temperature-threshold <degree_celsius>
仕様説明
snmp有効化
以下のコマンドでsnmpとsnmptrapの両方を有効化する事ができます。
Switch(config)# snmp-server agent
コミュニティ名の定義
snmptrapで使用するコミュニティ名を定義します。<entry_num>は任意の番号を指定する事ができ、1から10までを使用可能です。
Switch(config)# snmp-server host <entry_num> type [ v1 | v2 ] <addr> trap <community>
トラップの種類
通知するトラップの種類は変更する事が可能です。パナソニックNMOシリーズのデフォルト設定は以下の通りで、linkdownやPoEなどのトラップ通知がデフォルトで有効になっています。
Switch# show snmp SNMP Agent: Enabled SNMP Manager List: No. Status Previlege IP Address Community ---- -------- ----------- --------------- ---------------------------- 1 Enabled Read-Write 0.0.0.0 private 2 Enabled Read-Only 0.0.0.0 public 3 Disabled Read-Only 0.0.0.0 4 Disabled Read-Only 0.0.0.0 <omitted> Individual Trap SNMP Authentication Failure : Disabled Enable Link Up/Down Port : 1-26 PoE Trap Control : Enabled Temperature Trap Control : Disabled Temperature Threshold : 50 degree(s) Celsius FAN Failure : Enabled Switch#
トラップ通知の有効無効を変更するには以下のコマンドを使用します。
Switch(config)# snmp-server enable traps fan-fail Switch(config)# snmp-server enable traps linkupdown <port_list> Switch(config)# snmp-server enable traps poe Switch(config)# snmp-server enable traps snmp authentication Switch(config)# snmp-server enable traps poe Switch(config)# snmp-server enable traps temperature-control Switch(config)# snmp-server enable traps temperature-threshold <degree_celsius>
動作確認環境
以下の構成で動作確認を行います。
[SW1:MNO] hostname SW1 console inactivity-timer 0 telnet-server inactivity-timer 60 ip http server ! ip address 192.168.0.1 255.255.255.0 ip default-gateway 192.168.0.254
初期設定の全文は以下を参照下さい。
snmptrapの設定
snmptrap 有効化
以下のコマンドを入力し、snmptrapを有効にします。
[SW1:MNO] snmp-server agent
コミュニティ名の設定
コミュニティ名およびトラップの通知先を定義します。
[SW1:MNO] snmp-server host 1 type v2 192.168.0.1 trap TRAP_MNS
設定確認
“show snmp”というコマンドにより設定を確認します。
[SW1:MNO] SW1# show snmp <omitted> Trap Reciever List: No. Status Type IP Address Community ---- -------- ----------- --------------- ---------------------------- 1 Enabled v2 192.168.0.1 TRAP_MNS 2 Disabled v1 0.0.0.0 3 Disabled v1 0.0.0.0 4 Disabled v1 0.0.0.0 5 Disabled v1 0.0.0.0 6 Disabled v1 0.0.0.0 7 Disabled v1 0.0.0.0 8 Disabled v1 0.0.0.0 9 Disabled v1 0.0.0.0 10 Disabled v1 0.0.0.0 Individual Trap SNMP Authentication Failure : Disabled Enable Link Up/Down Port : 1-26 PoE Trap Control : Enabled Temperature Trap Control : Disabled Temperature Threshold : 50 degree(s) Celsius FAN Failure : Enabled SW1#
疎通確認
適当なリンクアップ/リンクダウンイベントと発生させ、そのイベントがsnmptrapdサーバへ届いている事を確認します。
[Host100] [root@localhost ~]# tail -n 1 /var/log/messages Feb 11 15:00:21 localhost snmptrapd[935]: 2014-02-11 15:00:21 <UNKNOWN> [UDP: [192.168.0.1]:162->[192.168.0.100]]:#012DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (686884) 1:54:28.84#011SNMPv2-MIB::snmpTrapOID.0 = OID: IF-MIB::linkDown#011IF-MIB::ifIndex.3 = INTEGER: 3#011IF-MIB::ifAdminStatus.3 = INTEGER: up(1)#011IF-MIB::ifOperStatus.3 = INTEGER: down(2)#011SNMPv2-MIB::snmpTrapEnterprise.0 = OID: SNMPv2-SMI::enterprises.396.5.4.1.19