第 17 章 NET SNMP (Simple Network Management Protocol)

简介:

目录

17.1. 安装SNMP
17.1.1. Ubuntu
17.1.1.1. snmpd.conf
17.1.1.2. SNMP v3
17.1.2. CentOS
17.1.2.1. Configure SNMPv3 on CentOS or RHEL
17.2. 配置SNMP
17.2.1. community 配置
17.2.2. 定义可操作的范围
17.3. SNMP 命令
17.3.1. snmpwalk
17.3.2. snmpget
17.3.3. snmptest
17.4. Cisco MBI
17.4.1. Cisco 3750
17.4.2. Cisco ASA 5550

17.1. 安装SNMP

17.1.1. Ubuntu

search package

netkiller@neo:~$ apt-cache search snmp
libsnmp-base - NET SNMP (Simple Network Management Protocol) MIBs and Docs
libsnmp-perl - NET SNMP (Simple Network Management Protocol) Perl5 Support
libsnmp-session-perl - Perl support for accessing SNMP-aware devices
libsnmp9 - NET SNMP (Simple Network Management Protocol) Library
libsnmp9-dev - NET SNMP (Simple Network Management Protocol) Development Files
snmp - NET SNMP (Simple Network Management Protocol) Apps
snmpd - NET SNMP (Simple Network Management Protocol) Agents
php5-snmp - SNMP module for php5
tcpdump - A powerful tool for network monitoring and data acquisition
			

安装

netkiller@neo:~$ sudo apt-get install snmp snmpd
			
17.1.1.1. snmpd.conf

配置 /etc/snmp/snmpd.conf

配置agentAddress

agentAddress  udp:172.16.1.3:161
				
#       sec.name  source          community
com2sec paranoid  default          chen

#           incl/excl subtree                          mask
view all    included  .1                               80
view system included  .iso.org.dod.internet.mgmt.mib-2.system
view system included  .iso.org.dod.internet.mgmt.mib-2.host
view system included  .iso.org.dod.internet.mgmt.mib-2.interfaces
				

.iso.org.dod.internet.mgmt.mib-2.host 可以使用命令 snmptranslate -Onf -IR hrStorageDescr得到

参考:http://www.mkssoftware.com/docs/man1/snmptranslate.1.asp

17.1.1.2. SNMP v3
neo@debian:~$ sudo /etc/init.d/snmpd stop
Stopping network management services: snmpd snmptrapd.

neo@debian:~$ sudo net-snmp-config --create-snmpv3-user -ro -a "netadminpassword" netadmin
adding the following line to /var/lib/snmp/snmpd.conf:
   createUser netadmin MD5 "netadminpassword" DES
adding the following line to /usr/share/snmp/snmpd.conf:
   rouser netadmin

neo@debian:~$ sudo /etc/init.d/snmpd start
Starting network management services: snmpd.
				

test

				
neo@debian:~$ snmpget -v 3 -u netadmin -l authNoPriv -a MD5 -A <passwd> 127.0.0.1 sysUpTime.0
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (6342) 0:01:03.42
				
				

With a different password this fails:

neo@debian:~$ snmpget -v 3 -u netadmin -l authNoPriv -a MD5 -A nopasswd 127.0.0.1 sysUpTime.0
snmpget: Authentication failure (incorrect password, community or key) (Sub-id not found: (top) -> sysUpTime)
				

Note that this can be stuck in a snmp.conf file in ~/.snmp:

				
neo@debian:~$ mkdir ~/.snmp
neo@debian:~$ vim ~/.snmp/snmp.conf
defSecurityName netadmin
defContext ""
defAuthType MD5
defSecurityLevel authNoPriv
defAuthPassphrase <netadminpassword>
defVersion 3
				
				

test

neo@debian:~$ snmpget 127.0.0.1 sysUpTime.0
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (39471) 0:06:34.71
				

17.1.2. CentOS

			
yum install net-snmp -y

cp /etc/snmp/snmpd.conf{,.original}

vim /etc/snmp/snmpd.conf <<VIM > /dev/null 2>&1
:62,62s/systemview/all/
:85,85s/^#//
:162,162s/syslocation Unknown/syslocation Neo/
:163,163s/syscontact Root <root@localhost>/syscontact Neo <netkiller@msn.com>/
:wq
VIM

service snmpd start
chkconfig snmpd on
			
			
17.1.2.1. Configure SNMPv3 on CentOS or RHEL
# yum install net-snmp-utils net-snmp-devel
# service snmpd stop
# net-snmp-create-v3-user -ro -A snmpv3pass -a MD5 -x DES snmpv3user
# service snmpd start
				

Test SNMPv3

# snmpwalk -u snmpv3user -A snmpv3pass -a MD5 -l authnoPriv 192.168.1.2 -v3				
		





原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。

目录
相关文章
|
22天前
|
运维 监控 Linux
zabbix中SNMP (Simple Network Management Protocol)
zabbix中SNMP (Simple Network Management Protocol)
44 10
|
Java
已解决Java.net.MalformedURLException异常的有效方法java.net.MalformedURLException: no protocol异常处理
已解决Java.net.MalformedURLException异常的有效方法java.net.MalformedURLException: no protocol异常处理
644 0
|
安全 Java Linux
Java调用ssl异常,javax.net.ssl.SSLHandshakeException: No appropriate protocol
Java调用ssl异常,javax.net.ssl.SSLHandshakeException: No appropriate protocol
1282 0
Java调用ssl异常,javax.net.ssl.SSLHandshakeException: No appropriate protocol
|
机器学习/深度学习 算法 计算机视觉
EagleEye: Fast Sub-net Evaluation for Efficient Neural Network Pruning(论文阅读)(下)
说明 动机 贡献 方法 发现 EagleEye剪枝算法 实验 实验1- 相关性的定量分析 实验2-基于自适应BN的评估方法的通用性 实验3-从修剪候选中选择最佳修剪策略的计算成本 实验4-Effectiveness of our proposed method 总结与讨论
155 0
EagleEye: Fast Sub-net Evaluation for Efficient Neural Network Pruning(论文阅读)(下)
|
机器学习/深度学习 算法 计算机视觉
EagleEye: Fast Sub-net Evaluation for Efficient Neural Network Pruning(论文阅读)(上)
说明 动机 贡献 方法 发现 EagleEye剪枝算法 实验 实验1- 相关性的定量分析 实验2-基于自适应BN的评估方法的通用性 实验3-从修剪候选中选择最佳修剪策略的计算成本 实验4-Effectiveness of our proposed method 总结与讨论
193 0
EagleEye: Fast Sub-net Evaluation for Efficient Neural Network Pruning(论文阅读)(上)
|
XML API Android开发
java.net.UnknownServiceException: CLEARTEXT communication to * not permitted by network
java.net.UnknownServiceException: CLEARTEXT communication to * not permitted by network
268 0
|
C# 设计模式 .NET
使用C# (.NET Core) 实现简单工厂(Simple Factory) 和工厂方法设计模式 (Factory Method Pattern)
本文源自深入浅出设计模式. 只不过我是使用C#/.NET Core实现的例子.   前言 当你看见new这个关键字的时候, 就应该想到它是具体的实现. 这就是一个具体的类, 为了更灵活, 我们应该使用的是接口(interface).
1450 0