snmp在企业网中的简单应用
SNMP簡介:
目前網絡中用得最廣泛的網絡管理協議是SNMP(Simple Network Management Protocol,簡單網絡管理協議)。SNMP是被廣泛接受并投入使用的工業標準,用于保證管理信息在網絡中任意兩點間傳送,便于網絡管理員在網絡上的任何節點檢索信息、修改信息、定位故障、完成故障診斷、進行容量規劃和生成報告。
SNMP采用輪詢機制,只提供最基本的功能集,特別適合在小型、快速和低價格的環境中使用。SNMP(應用層協議但是必須走傳輸層)的實現基于無連接的傳輸層協議UDP(162端口),因此可以實現和眾多產品的無障礙連接。
SNMP的工作機制
SNMP分為NMS和Agent兩部分:
1 NMS(Network Management Station,網絡管理站)是運行客戶端程序的工作站,目前常用的網管平臺有QuidView、Sun NetManager和IBM NetView。
2 Agent是運行在網絡設備上的服務器端軟件。
兩者之間的工作的過程
1 NMS可以向Agent發出GetRequest、GetNextRequest和SetRequest報文,Agent接收到NMS的這些請求報文后,根據報文類型進行Read或Write操作,生成Response報文,并將報文返回給NMS。
2 Agent在設備發生異常情況或狀態改變時(如設備重新啟動),也會主動向NMS發送Trap報文,向NMS匯報所發生的事件
3 Trap是被管理設備不經請求,主動向NMS發送的信息,用于報告一些緊急的重要事件(如被管理設備重新啟動等)
NMP的版本
目前,設備中的SNMP Agent支持SNMP v3版本,兼容SNMP v1版本、SNMP v2C版本。
SNMP v3采用用戶名和密碼認證方式。
SNMP v1、SNMP v2C采用團體名(Community Name)認證,非設備認可團體名的SNMP報文將被丟棄。SNMP團體名用來定義SNMP NMS和SNMP Agent的關系。團體名起到了類似于密碼的作用,可以限制SNMP NMS訪問設備上的SNMP Agent
設置團體名對MIB對象的訪問權限為讀寫權限(write)或者只讀權限(read)。具有只讀權限的團體名只能對設備信息進行查詢,而具有讀寫權限的團體名還可以對設備進行配置
MIB樹結構
MIB(Management Information Base,管理信息庫)的作用就是用來描述樹的層次結構,它是所監控網絡設備的標準變量定義的集合。管理對象可以用一串數字{1.2.1.1}唯一確定,這串數字是管理對象的對象標識符(Object Identifier,oid)(管理信息數據庫是用oid來描述的)
設備支持的MIB 在SNMP報文中用管理變量來描述設備中的管理對象。為了唯一標識設備中的管理對象,SNMP用層次結構命名方案來識別管理對象。整個層次結構就像一棵樹,樹的節點表示管理對象。每一個節點,都可以用從根開始的一條路徑唯一地標識(樹狀結構)
若為1.3.6.1.2.1.7則是訪問UDP
再若如圖
則是訪問的是udp下邊的一個進來的數據包
案例:
目的:為實現交換機與路由器和pc之間實現統一的管理在NMS服務器上呈現
設備 兩臺路由器和一臺交換機
軟件:what’s up 來充當網管軟件
拓撲圖
##############################################################################################################################################################
一
交換機的配置
#進入系統視圖
<Quidway>sys
Enter system view, return to user view with Ctrl+Z.
#配置交換機的地址
[Quidway]int vlan 1
[Quidway-Vlan-interface1]ip add 192.168.5.200 24
^
% Wrong parameter found at '^' position.
[Quidway-Vlan-interface1]ip add 192.168.5.200 ?
X.X.X.X IP mask
[Quidway-Vlan-interface1]ip add 192.168.5.200 255.255.255.255
% Wrong IP address!
[Quidway-Vlan-interface1]ip add 192.168.5.200 255.255.255.0
[Quidway-Vlan-interface1]quit
#配置網關也就是默認路由
[Quidway]ip route-static 0.0.0.0 0.0.0.0 192.168.5.1
#創建用戶,密碼以及用戶的telnet的登陸方式
[Quidway]local-user user1
New local user added.
[Quidway-luser-user1]password simple 123
[Quidway-luser-user1]service-
[Quidway-luser-user1]service-type telnet le
[Quidway-luser-user1]service-type telnet level 3.
[Quidway-luser-user1]quit
#進入用戶虛擬接口 配置登陸方式
[Quidway]user-interface vty 0 4
[Quidway-ui-vty0-4]auth
[Quidway-ui-vty0-4]authentication-mode sc
[Quidway-ui-vty0-4]authentication-mode scheme
#啟動snmp
[Quidway]snmp-agent
#配置團體的可讀可寫的驗證鑰匙
[Quidway]snmp community read public
[Quidway]snmp community write private
#配置snmp的版本 支持所有的版本
[Quidway]snmp sys-info version all
#啟動trap觸發機制
[Quidway]snmp trap enable
#配置nms服務器的地址以及驗證的密碼是public(觸發更新的時候驗證的密碼)
[Quidway]snmp target-host trap add udp-domain 192.168.5.100 params securityname ?
STRING<1-32> Specify the character string of security name
[Quidway]snmp target-host trap add udp-domain 192.168.5.100 params securityname public
##############################################################################################################################################################
二
路由器B的配置
#改名字
[Router]sysname Rb
[Rb]
#進入相應的端口配地址
[Rb]int eth0
[Rb-Ethernet0]ip add 192.168.5.1 24
[Rb-Ethernet0]
%01:07:52: Line protocol ip on the interface Ethernet0 is UP
[Rb-Ethernet0]
#測試與交換機之間的連通性
[Rb-Ethernet0]ping 192.168.5.200
PING 192.168.5.200: 56 data bytes, press CTRL_C to break
Reply from 192.168.5.200: bytes=56 Sequence=0 ttl=255 time = 32 ms
Reply from 192.168.5.200: bytes=56 Sequence=1 ttl=255 time = 14 ms
Reply from 192.168.5.200: bytes=56 Sequence=2 ttl=255 time = 23 ms
Reply from 192.168.5.200: bytes=56 Sequence=3 ttl=255 time = 15 ms
Reply from 192.168.5.200: bytes=56 Sequence=4 ttl=255 time = 21 ms
--- 192.168.5.200 ping statistics ---
5 packets transmitted
5 packets received
0.00% packet loss
round-trip min/avg/max = 14/21/32 ms
#進入相應的端口配地址
[Rb-Ethernet0]int s0
[Rb-Serial0]ip add 192.168.4.2 24
[Rb-Serial0]
%01:08:36: Line protocol ip on the interface Serial0 is UP
[Rb-Serial0]
[Rb-Serial0]quit
#配置默認路由
[Rb]ip route-static 192.168.2.0 24 192.168.4.1
#啟動snmp-agent
[Rb]snmp-agent
#配置snmp-agent的團體可讀的鑰匙和可寫的密碼
[Rb]snmp community read public
[Rb]snmp community write private
#snmp-agent的版本(全都支持)
[Rb]snmp sys-info version all
#開啟觸發驗證機制
[Rb]snmp trap enable
#配置觸發更新的目標地址跟密鑰
[Rb]snmp target-host trap address 192.168.5.100 sec public
三.
路由器s的配置
#進入系統視圖并修改名字
[Router]sysname Rs
[Rs]
#進入端口配地址
[Rs]int eth0
[Rs-Ethernet0]ip add 192.168.2.1 24
[Rs-Ethernet0]int s0
[Rs-Serial0]ip add 192.168.4.1
%01:09:41: Interface Ethernet0 is UP
%01:09:41: Line protocol ip on the interfa
[Rs-Serial0]ip add 192.168.4.1 24
[Rs-Serial0]
%01:10:42: Line protocol ip on the interface Serial0 is UP
[Rs-Serial0]
[Rs-Serial0]shut
% Interface Serial0 is down
[Rs-Serial0]
%01:11:26: Interface Serial0 is DOWN
[Rs-Serial0]undo shut
% Interface Serial0 is reset
%01:11:46: Interface Serial0 is UP
%01:11:47: Line protocol ip on the interface Serial0 is UP
#測試與路由器b的連通性
[Rs-Serial0]ping 192.168.4.2
PING 192.168.4.2: 56 data bytes, press CTRL_C to break
Reply from 192.168.4.2: bytes=56 Sequence=0 ttl=255 time = 25 ms
Reply from 192.168.4.2: bytes=56 Sequence=1 ttl=255 time = 25 ms
Reply from 192.168.4.2: bytes=56 Sequence=2 ttl=255 time = 25 ms
Reply from 192.168.4.2: bytes=56 Sequence=3 ttl=255 time = 25 ms
Reply from 192.168.4.2: bytes=56 Sequence=4 ttl=255 time = 25 ms
--- 192.168.4.2 ping statistics ---
5 packets transmitted
5 packets received
0.00% packet loss
round-trip min/avg/max = 25/25/25 ms
[Rs-Serial0]quit
#配置默認路由
[Rs]ip route-static 192.168.5.0 24 192.168.4.2
#打開snmp-agent
[Rs] snmp-agent
#配置團體的可讀與可寫的密鑰
[Rs]snmp community ?
read Specify read-only access
write Specify read-write access
[Rs]snmp community read public
[Rs]snmp community write private
#設置配置的版本(支持所有的版本)
[Rs]snmp sys-info version all
#打開觸發機制
[Rs]snmp trap enable
#配置觸發機制與服務器之間的驗證密碼是public以及服務器的地址
[Rs]snmp target-host trap add 192.168.5.100 sec public
在服務器上安裝網管軟件what’s up
#點擊安裝
#寫出根節點的設備地址,以及發出驗證的密碼口令
#設置配置的收索設備上的服務
#收索過程
#收索網絡中的設備
#然后編輯收索之后形成的網絡拓撲圖
然后用來管理網絡拓撲中的機器
轉載于:https://blog.51cto.com/langzijishu/982076
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的snmp在企业网中的简单应用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: TurboMail邮件服务器荣膺“201
- 下一篇: VC++动态链接库(DLL)编程深入浅出