SNMP技术
SNMP协议详解
简单网络管理协议(SNMP:Simple Network Management Protocol)是由互联网工程任务组(IETF:Internet Engineering Task Force )定义的一套网络管理协议。该协议基于简单网关监视协议(SGMP:Simple Gateway Monitor Protocol)。利用SNMP,一个管理工作站可以远程管理所有支持这种协议的网络设备,包括监视网络状态、修改网络设备配置、接收网络事件警告等。 虽然SNMP开始是面向基于IP的网络管理,但作为一个工业标准也被成功用于话网络管理。
1. SNMP基本原理
SNMP采用了Client/Server模型的特殊形式:代理/管理站模型。对网络的管理与维护是通过管理工作站与SNMP代理间的交互工作完成的。每个SNMP从代理负责回答SNMP管理工作站(主代理)关于MIB定义信息的各种查询。
实验器材:两台华为路由器,一台s2000交换机,两台pc机,虚拟机windows(web服务器)和linux(ftp服务器)
配置r1:
[r1]int e0
[r1-Ethernet0]ip add 192.168.3.1 24
[r1]int s0
[r1-Serial0]ip add 192.168.2.1 24
[r1]snmp-agent
[r1]snmp-agent community read public
[r1]snmp-agent community write private
[r1]snmp-agent sys-info contact admin1
[r1]snmp-agent sys-info location PC1
[r1]snmp-agent sys-info version all
[r1]snmp-agent target-host trap add 192.168.1.100 securityname 123456
[r1]ip route 192.168.3.0 255.255.255.0 192.168.2.2
配置r2:
[r2]ip route 192.168.1.0 24 192.168.2.1(默认路由)
[r2]snmp-agent
SNMP-agent has been running
[r2]snmp-agent community read public
[r2]snmp-agent community write private
[r2]snmp-agent sys-info contact admin2
[r2]snmp-agent sys-info location 2jifang
[r2]snmp-agent sys-info version all
[r2]snmp-agent trap enable
[r2]snmp-agent target-host trap address 192.168.1.100 securityname 123456
[r2]inter e1
[r2-Ethernet1]ip address 192.168.3.254 24
[r2-Ethernet1]inter s0
[r2-Serial0]ip address 192.168.2.2 24
[r2-Serial0]
%02:18:21: Line protocol ip on the interface Serial0 is UP
[r2-Serial0]
[r2-Serial0]shut
% Interface Serial0 is shut down
[r2-Serial0]
%02:18:24: Interface Serial0 is DOWN
[r2-Serial0]undo shut
% Interface Serial0 is reset
[r2-Serial0]
%02:18:32: Interface Serial0 is UP
%02:18:35: Line protocol ip on the interfac
配置sw1:
[S2]snmp-agent
[S2]snmp-agent community read public
[S2]snmp-agent community write private
[S2]snmp-agent sys-info contact admin3
[S2]snmp-agent sys-info location zhuji3
[S2]snmp-agent sys-info version all
[S2]snmp-agent target-host trap add udp-domain 192.168.1.100 udp-port 162 params securityname 123456
[S2]snmp-agent trap enable
[S2]local-user user1
[S2-luser-user1]password simple 123
[S2-luser-user1]service-type telnet level 3
[s2]user-interface vty 0 4
[S2]ip route 192.168.1.0 255.255.255.0 192.168.3.1
[S2]int vlan 1
[S2-Vlan-interface1]ip add 192.168.3.254 255.255.255.0
Linux上安装snmp服务:
[root@localhost Server]# rpm -ivh lm_sensors-2.10.7-4.el5.i386.rpm
warning: lm_sensors-2.10.7-4.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...
########################################### [100%]
1:lm_sensors ########################################### [100%]
[root@localhost Server]#
[root@localhost Server]# ll net-snmp*
-r--r--r-- 86 root root 712539 Jul 29 2009 net-snmp-5.3.2.2-7.el5.i386.rpm
-r--r--r-- 99 root root 1995850 Jul 29 2009 net-snmp-devel-5.3.2.2-7.el5.i386.rpm
-r--r--r-- 99 root root 1317716 Jul 29 2009 net-snmp-libs-5.3.2.2-7.el5.i386.rpm
-r--r--r-- 86 root root 201604 Jul 29 2009 net-snmp-perl-5.3.2.2-7.el5.i386.rpm
-r--r--r-- 86 root root 189477 Jul 29 2009 net-snmp-utils-5.3.2.2-7.el5.i386.rpm
[root@localhost Server]# rpm -ivh net-snmp-5.3.2.2-7.el5.i386.rpm
warning: net-snmp-5.3.2.2-7.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...
########################################### [100%]
1:net-snmp ########################################### [100%]
[root@localhost Server]#
[root@localhost Server]# service snmpd restart
Stopping snmpd:
[ OK ]
Starting snmpd:
[ OK ]
安装ftp服务:
[root@localhost Server]# rpm -ivh vsftpd-2.0.5-16.el5.i386.rpm
warning: vsftpd-2.0.5-16.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing...
########################################### [100%]
1:vsftpd ########################################### [100%]
[root@localhost Server]# service ftpd start
ftpd: unrecognized service
[root@localhost Server]# service vsftpd start
Starting vsftpd for vsftpd:
[ OK ]
[root@localhost Server]#
Windows上启动SNMP:
把windows作为web服务器。
在主机192.168.1.100上安装whats up软件,用whats up来监测网络中的通信情况,从而得到整个网络结构拓扑图。