SNMP 基础知识
1、SNMP简介
2、SNMP术语
3、SNMP的网络架构
4、MIB简介
5、SNMP协议的实现及常用指令
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
[email protected] ~] # yum -y install net-snmp net-snmp-utils #两个包都安装上
[[email protected] ~] # rpm -ql net-snmp-utils #此软件包生成了众多工具
/usr/bin/encode_keychange
/usr/bin/snmpbulkget
/usr/bin/snmpbulkwalk
/usr/bin/snmpdelta
/usr/bin/snmpdf
/usr/bin/snmpget
/usr/bin/snmpgetnext
/usr/bin/snmpinform
/usr/bin/snmpnetstat
/usr/bin/snmpset
/usr/bin/snmpstatus
/usr/bin/snmptable
/usr/bin/snmptest
/usr/bin/snmptranslate
/usr/bin/snmptrap
/usr/bin/snmpusm
/usr/bin/snmpvacm
/usr/bin/snmpwalk
[[email protected] ~] # rpm -ql net-snmp
/etc/rc .d /init .d /snmpd #服务脚本
/etc/rc .d /init .d /snmptrapd #服务脚本,
/etc/snmp
/etc/snmp/snmpd .conf #配置文件
/etc/snmp/snmptrapd .conf #配置文件
/etc/sysconfig/snmpd
/etc/sysconfig/snmptrapd
/usr/bin/net-snmp-create-v3-user
/usr/bin/snmpconf
/usr/sbin/snmpd
/usr/sbin/snmptrapd
|
1
2
3
4
5
6
7
8
|
[[email protected] ~] # service snmpd start
Starting snmpd: [ OK ]
[[email protected] ~] # service snmptrapd start
Starting snmptrapd: [ OK ]
在nod1上也安装上net-snmp:
[[email protected] ~] # yum -y install net-snmp
[[email protected] ~] # service snmpd start
Starting snmpd: [ OK ]
|
1
2
3
|
# First, map the community name "public" into a "security name"
# sec.name source community
com2sec notConfigUser default public
|
1
2
3
|
# First, map the community name "public" into a "security name"
# sec.name source community
com2sec notConfigUser 192.168.0.0 /24 testpublic
|
1
2
3
4
5
|
####
# Second, map the security name into a group name:
# groupName securityModel securityName
group notConfigGroup v1 notConfigUser
group notConfigGroup v2c notConfigUser
|
1
2
3
4
|
# Make at least snmpwalk -v 1 localhost -c public system fast again.
# name incl/excl subtree mask(optional)
view systemview included .1.3.6.1.2.1.1
view systemview included .1.3.6.1.2.1.25.1.1
|
1
2
3
4
|
[[email protected] ~] # snmp
snmpbulkget snmpd snmpget snmpnetstat snmptable snmptrap snmpvacm
snmpbulkwalk snmpdelta snmpgetnext snmpset snmptest snmptrapd snmpwalk
snmpconf snmpdf snmpinform snmpstatus snmptranslate snmpusm
|
1
2
3
4
5
6
|
snmpget [COMMON OPTIONS] [-Cf] OID [OID]...
- v 1|2c|3 specifies SNMP version to use
-c COMMUNITY 指定community
举例:
[[email protected] ~] # snmpget -v 2c -c testpublic 192.168.0.201 SNMPv2-MIB::sysName.0
SNMPv2-MIB::sysName.0 = STRING: nod1 #获取到192.168.0.201的主机名
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
- v 1|2c|3 specifies SNMP version to use
-c COMMUNITY 指定community
举例:
[[email protected] ~] # snmpwalk -v 2c -c testpublic 192.168.0.201 interfaces #获取远程主机MIB中interfaces子树的全部信息
IF-MIB::ifNumber.0 = INTEGER: 2
IF-MIB::ifIndex.1 = INTEGER: 1
IF-MIB::ifIndex.2 = INTEGER: 2
IF-MIB::ifDescr.1 = STRING: lo
IF-MIB::ifDescr.2 = STRING: eth0
IF-MIB::ifType.1 = INTEGER: softwareLoopback(24)
IF-MIB::ifType.2 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifMtu.1 = INTEGER: 16436
IF-MIB::ifMtu.2 = INTEGER: 1500
IF-MIB::ifSpeed.1 = Gauge32: 10000000
IF-MIB::ifSpeed.2 = Gauge32: 0
IF-MIB::ifPhysAddress.1 = STRING:
IF-MIB::ifPhysAddress.2 = STRING: 0:c:29:c6:f7:7a
IF-MIB::ifAdminStatus.1 = INTEGER: up(1)
IF-MIB::ifAdminStatus.2 = INTEGER: up(1)
IF-MIB::ifOperStatus.1 = INTEGER: up(1)
IF-MIB::ifOperStatus.2 = INTEGER: up(1)
IF-MIB::ifLastChange.1 = Timeticks: (0) 0:00:00.00
IF-MIB::ifLastChange.2 = Timeticks: (0) 0:00:00.00
IF-MIB::ifInOctets.1 = Counter32: 0
IF-MIB::ifInOctets.2 = Counter32: 7789122
IF-MIB::ifInUcastPkts.1 = Counter32: 0
IF-MIB::ifInUcastPkts.2 = Counter32: 7687
IF-MIB::ifInNUcastPkts.1 = Counter32: 0
IF-MIB::ifInNUcastPkts.2 = Counter32: 0
IF-MIB::ifInDiscards.1 = Counter32: 0
IF-MIB::ifInDiscards.2 = Counter32: 0
IF-MIB::ifInErrors.1 = Counter32: 0
IF-MIB::ifInErrors.2 = Counter32: 0
IF-MIB::ifInUnknownProtos.1 = Counter32: 0
IF-MIB::ifInUnknownProtos.2 = Counter32: 0
IF-MIB::ifOutOctets.1 = Counter32: 0
IF-MIB::ifOutOctets.2 = Counter32: 484581
IF-MIB::ifOutUcastPkts.1 = Counter32: 0
IF-MIB::ifOutUcastPkts.2 = Counter32: 5040
IF-MIB::ifOutNUcastPkts.1 = Counter32: 0
IF-MIB::ifOutNUcastPkts.2 = Counter32: 0
IF-MIB::ifOutDiscards.1 = Counter32: 0
IF-MIB::ifOutDiscards.2 = Counter32: 0
IF-MIB::ifOutErrors.1 = Counter32: 0
IF-MIB::ifOutErrors.2 = Counter32: 0
IF-MIB::ifOutQLen.1 = Gauge32: 0
IF-MIB::ifOutQLen.2 = Gauge32: 0
IF-MIB::ifSpecific.1 = OID: SNMPv2-SMI::zeroDotZero
IF-MIB::ifSpecific.2 = OID: SNMPv2-SMI::zeroDotZero
|
1
2
3
4
5
|
举例:
[[email protected] ~] # snmptranslate -On -IR system (-On表示以数字格式输出,-IR表示随机访问MIB)
.1.3.6.1.2.1.1
[[email protected] ~] # snmptranslate -Onf -IR system (-f表示列出名称型的OID)
.iso.org.dod.internet.mgmt.mib-2.system
|