SNMPv3 の Trap受信設定をしてみる(CentOS7)


1. はじめに

Centos7のサーバー上でLBからのSNMPv3 Trap受信設定をした際の備忘録です。
SNMPv3関連の情報があまり見当たらなかったので記事にします。

2. サーバーへのTrap受信設定方法

1.まずはfirewalldをオフにする
systemctl stop firewalld
or
systemctl disable firewalld

2.「/etc/snmp/snmptrapd.conf」に設定を追加

# Example configuration file for snmptrapd
#
# No traps are handled by default, you must edit this file!
#
# authCommunity   log,execute,net public
# traphandle SNMPv2-MIB::coldStart    /usr/bin/bin/my_great_script cold

createUser -e <EngineID> <UserName> SHA <Password> AES
authuser log <UserName>

3.SNMP Trapの動作確認


[daikon@CentOS7 ~]$ sudo snmptrapd -f -C -c /etc/snmp/snmptrapd.conf -Le
NET-SNMP version 5.7.2
~Trap受信時にログが出力される~

4. trapが出力されない時。。。

1.「No access configuration」が出力される場合
「/etc/snmp/snmptrapd.conf」の設定内容が不足しています。

[root@CentOS7-149 snmp]#  snmptrapd -f -C -c /etc/snmp/snmptrapd.conf -Le
Warning: no access control information configured.
  (Config search path: /etc/snmp:/usr/share/snmp:/usr/lib64/snmp:/root/.snmp)
This receiver will *NOT* accept any incoming notifications.
NET-SNMP version 5.7.2
No access configuration - dropping trap.
No access configuration - dropping trap.

2.「Authentication failed」が出力される場合
設定するパスワードが間違っています。

[disaito@CentOS7-149 ~]$ sudo snmptrapd -f -C -c /etc/snmp/snmptrapd.conf -Le
NET-SNMP version 5.7.2
Authentication failed for SNMPv3userMD5

3.何も出力されない場合
ユーザーID,Engine IDを間違えています。

[disaito@CentOS7-149 ~]$ sudo snmptrapd -f -C -c /etc/snmp/snmptrapd.conf -Le
NET-SNMP version 5.7.2



5. 参考

[公式ドキュメント]
http://www.net-snmp.org/wiki/index.php/TUT:Configuring_snmptrapd_to_receive_SNMPv3_notifications#Configuring_a_SNMPv3_TRAP_User

4. 終わりに

参考になれば幸いです。