天天看點

SNMP在企業網中的應用

 一、原理介紹:

1、SNMP 簡介: 

    SNMP(Simple Network Management Protocol,簡單網絡管理協定)是網絡中用得最廣泛的網絡管理協定 。SNMP是被廣泛接受并投入使用的工業标準,用于保證管理資訊在網絡中任意兩點間傳送,便于網絡管理者在網絡上的任何節點檢索資訊、修改資訊、定位故障、完成故障診斷、進行容量規劃和生成報告SNMP 采用輪詢機制,隻提供最基本的功能集,特别适合在小型、快速和低價格的環境中使用。SNMP 的實作基于無連接配接的傳輸層協定 UDP,是以可以實作和衆多産品的無障礙連接配接。

2、SNMP 的工作機制: 

    SNMP 分為 NMS 和 Agent 兩部分: 

    NMS  (Network Management Station,網絡管理站)是運作用戶端程式的工作站,目前常用的網管平台有QuidView、Sun NetManager 和 IBM NetView。 

    Agent 是運作在網絡裝置上的伺服器端軟體。 

    NMS 可以向 Agent 發出 GetRequest、GetNextRequest 和 SetRequest 封包,Agent接收到 NMS  的這些請求封包後,根據封包類型進行 Read  或 Write  操作,生成Response 封包,并将封包傳回給 NMS。  

    Agent 在裝置發生異常情況或狀态改變時(如裝置重新啟動),也會主動向 NMS 發送 Trap 封包,向 NMS 彙報所發生的事件。

3、SNMP 的管理對象: 

    裝置中的管理對象在SNMP封包中用管理變量來描述,為了唯一辨別裝置中的管理對象,SNMP用層次結構命名方案來識别管理對象。整個層次結構就象一棵樹,樹的節點表示管理對象,如圖下圖所示。每一個節點,都可以用從根開始的一條路徑别無二義地辨別。

    在上圖中,管理對象 B 可以用一串數字{1.2.1.1}唯一确定,這串數字是管理對象的Object Identifier(客體辨別符)。而MIB(Management Information Base)的作用就是用來描述樹的層次結構,它是所監控網絡裝置的标準變量定義的集合。

二、案例:

1、拓撲圖:

<a href="http://cexpert.blog.51cto.com/attachment/201209/3/5251990_1346679051bVl3.png"></a>

2、實驗裝置: 

    華為路由器R2621 一台; 

    華為交換機s2000系列 一台; 

    華為防火牆一台;

3、配置步驟:

1)配置交換機:

##更改交換機的名稱:

sysname switch

##配置管理vlan位址:

interface Vlan-interface1

ip address 192.168.10.2 255.255.255.0

quit

##配置一條預設路由:

ip route-static 0.0.0.0 0.0.0.0 192.168.10.1 preference 60

##将交換機配置稱為SNMP的agent:

snmp-agent  //在交換機上啟動SNMP的agent

snmp-agent community read public  //設定隻讀權限的密鑰

snmp-agent community write private  //設定可寫權限的密鑰

snmp-agent sys-info contact zhangsan  //設定交換機裝置對應的聯系人

snmp-agent sys-info location beijing  //設定交換機裝置對應的聯系位址

snmp-agent sys-info version all  //支援所有的SNMP的版本

snmp-agent target-host trap address udp-domain 192.168.10.10 params securityname public  //發送給目标主機的位址和對應的鑰匙

2)配置路由器:

sysname Router

##配置接口位址

interface Ethernet0

ip address 192.168.10.1 255.255.255.0

interface Ethernet1

ip address 10.1.1.2 255.255.255.0

##配置一條靜态路由:

ip route-static 192.168.20.0 255.255.255.0 10.1.1.1 preference 60

##将路由器配置稱為SNMP的agent:

snmp-agent

snmp-agent sys-info contact lisi   //設定交換機裝置對應的聯系人

snmp-agent target-host trap address 192.168.10.10 securityname public  //發送給目标主機的位址和對應的鑰匙

3)配置防火牆:

sysname firewall

##将接口eth0/0和eth0/1劃分到不同的區域:

firewall zone trust  //将接口eth0/0劃分到trust區域

add interface Ethernet0/0

firewall zone untrust  //将接口eth0/1劃分到untrust區域

add interface Ethernet0/1

##配置接口位址:

interface Ethernet0/0

ip address 192.168.20.1 255.255.255.0

interface Ethernet0/1

ip address 10.1.1.1 255.255.255.0

ip route-static 192.168.10.0 255.255.255.0 10.1.1.2 preference 60

##将防火牆配置稱為SNMP的agent:

snmp-agent sys-info contact wangwu  //設定交換機裝置對應的聯系人

snmp-agent sys-info location shanghai  //設定交換機裝置對應的聯系位址

4、測試:

NMS的位址:

<a href="http://cexpert.blog.51cto.com/attachment/201209/3/5251990_1346679051HgAB.png"></a>

測試網絡連通性:

<a href="http://cexpert.blog.51cto.com/attachment/201209/3/5251990_1346679052cTnD.png"></a>

     //NMS與遠端伺服器是連通的;

掃描SNMP監控裝置:

<a href="http://cexpert.blog.51cto.com/attachment/201209/3/5251990_13466790615xPY.png"></a>

<a href="http://cexpert.blog.51cto.com/attachment/201209/3/5251990_1346679064l3TR.png"></a>

<a href="http://cexpert.blog.51cto.com/attachment/201209/3/5251990_1346679065hbf3.png"></a>

<a href="http://cexpert.blog.51cto.com/attachment/201209/3/5251990_13466790690eWq.png"></a>

開始搜尋:

<a href="http://cexpert.blog.51cto.com/attachment/201209/3/5251990_1346679069eut7.png"></a>

<a href="http://cexpert.blog.51cto.com/attachment/201209/3/5251990_13466790726gOu.png"></a>

<a href="http://cexpert.blog.51cto.com/attachment/201209/3/5251990_1346679076zziV.png"></a>

<a href="http://cexpert.blog.51cto.com/attachment/201209/3/5251990_1346679076GFdc.png"></a>

自動生成的拓撲圖:

<a href="http://cexpert.blog.51cto.com/attachment/201209/3/5251990_1346679086k00f.png"></a>

整理出簡易拓撲圖:

<a href="http://cexpert.blog.51cto.com/attachment/201209/3/5251990_1346679092zsu5.png"></a>

當斷開防火牆的接口eth0/1後,拓撲圖中鍊路狀态的回報:

<a href="http://cexpert.blog.51cto.com/attachment/201209/3/5251990_1346679092cTym.png"></a>

斷開路由器的eth1,鍊路狀态的回報:

<a href="http://cexpert.blog.51cto.com/attachment/201209/3/5251990_1346679096pGmJ.png"></a>

還可以,通過snmp管理工具登入相應的裝置進行管理:

<a href="http://cexpert.blog.51cto.com/attachment/201209/3/5251990_1346679099zBHj.png"></a>

本文轉自 cexpert 51CTO部落格,原文連結:http://blog.51cto.com/cexpert/981083

繼續閱讀