net-snmp インストール
net-snmpのインストールおよび設定
net-snmpインストール
yumでインストール
snmpd インストール
[root@sun ~] # yum install -y net-snmp
Setting up Install Process
Setting up repositories
Reading repository metadata in from local files
Parsing package install arguments
Resolving Dependencies
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for net-snmp to pack into transaction set.
net-snmp-5.1.2-11.EL4.6.i 100% |=========================| 491 kB 00:15
---> Package net-snmp.i386 0:5.1.2-11.EL4.6 set to be updated
--> Running transaction check
--> Processing Dependency: libsensors.so.3 for package: net-snmp
--> Restarting Dependency Resolution with new changes.
--> Populating transaction set with selected packages. Please wait.
---> Downloading header for lm_sensors to pack into transaction set.
lm_sensors-2.8.7-2.40.3.i 100% |=========================| 426 kB 00:15
---> Package lm_sensors.i386 0:2.8.7-2.40.3 set to be updated
--> Running transaction check
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
net-snmp i386 5.1.2-11.EL4.6 base 491 k
Installing for dependencies:
lm_sensors i386 2.8.7-2.40.3 base 426 k
Transaction Summary
=============================================================================
Install 2 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 917 k
Downloading Packages:
(1/2): net-snmp-5.1.2-11. 100% |=========================| 491 kB 00:18
(2/2): lm_sensors-2.8.7-2 100% |=========================| 426 kB 00:11
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: lm_sensors ######################### [1/2]
Installing: net-snmp ######################### [2/2]
Installed: net-snmp.i386 0:5.1.2-11.EL4.6
Dependency Installed: lm_sensors.i386 0:2.8.7-2.40.3
Complete!
snmp コマンドのインストール
# yum install -y net-snmp-devel
ログは省略
# yum install -y net-snmp-utils
ログは省略
net-snmpの設定
snmp.conf編集
yum でインストールした場合
# vi /etc/snmp/snmpd.conf※ソースからインストールした場合snmpd.confをコピーしてsnmpd.confを作成します。
# cp EXAMPLE.conf /usr/local/share/snmp/snmpd.conf設定項目
# vi /usr/local/share/snmp/snmpd.conf
- com2sec (ネットワーク範囲とコミュニティ名)
- group (セキュリティについて設定)
- view (snmpにて参照可能な情報範囲の指定)
- access (アクセスコントロールの設定)
com2sec ネットワークとコミュニティ名の設定
デフォルト値com2sec notConfigUser default public設定変更後
#com2sec notConfigUser default public ←コメント化設定の説明
com2sec local localhost public
com2sec mynetwork 192.168.0.0/24 public
セキュリティ名「local」で対応ネットワークが「localhost(127.0.0.1)」
コミュニティ名が「hoge」であることを示している。
セキュリティ名・コミュニティ名はそれぞれ任意に設定すること。
ネットワークについては、各自のネットワークに合わせて設定
group セキュリティについての設定
com2secで設定したセキュリティ名とsnmpのセキュリティ名を組み合わせて セキュリティグループ名を設定します。
デフォルト値group notConfigGroup v1 notConfigUser設定変更後
group notConfigGroup v2c notConfigUser
#group notConfigGroup v1 notConfigUser ←コメント化する。
#group notConfigGroup v2c notConfigUser ←コメント化する。
group local_group v1 local
group local_group v2c local
group local_group usm local
group mynet_group v1 mynetwork
group mynet_group v2c mynetwork
group mynet_group usm mynetwork
view MIBの参照範囲指定
どこまでのMIBツリーを参照させるかの範囲を設定する。デフォルト値
view systemview included .1.3.6.1.2.1.1設定変更後
view systemview included .1.3.6.1.2.1.25.1.1
すべてのmibツリーを参照させる「all_view」というview名を作成します。
#view systemview included .1.3.6.1.2.1.1 ←コメント化する。
#view systemview included .1.3.6.1.2.1.25.1.1 ←コメント化する。
view all_view included .1
access アクセス制限
上記までに設定したgroupおよびviewを組み合わせて、どのようなアクセスを認めるのかを設定します。
書式
access [ group ] [contxt] [モデル名] [認証設定][contextマッチ方法][read権限][write権限][通知権限]
access notConfigGroup "" any noauth exact systemview none none設定変更後
デフォルトの設定はコメントとして無効化して、 groupの箇所で作成した各グループともに、すべてのmib情報を参照はできるが書き込みは禁止とし、 認証無しという設定にしました。
#access notConfigGroup "" any noauth exact systemview none none ←コメント化
access local_group "" any noauth exact all_view none none
access mynet_group "" any noauth exact all_view none none
net-snmp起動方法
# /etc/init.d/snmpd start
snmpd を起動中: [ OK ]
自動起動
自動起動設定
# chkconfig snmpd on
自動起動設定確認
# chkconfig --list snmpd
snmpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off