CCIE試驗備考之交換security(5)

第五部分  IP源保護(IP Source Guard)
IPSG提供檢測機制來確保單個接口所接收到的數據包能夠被各個接口所接收。如果檢查成功通過,那麼就將許可數據包;否則就會發生違背策略的活動。IPSG不僅能夠確保第2層網絡中終端設備的IP地址不會被劫持,而且還能確保非授權設備不能通過自己指定IP地址的方式來訪問網絡或導致網絡崩潰及癱瘓。
在DHCP監聽綁定表或靜態IP源綁定的幫助下,IPSG能夠獲得有效的源端口信息。在不信任端口上啓用dhcp snooping和ip源保護之後,交換機將阻止除了dhcp數據包之外的所有流量。一旦DHCP服務器分配了IP地址,那麼就更新dhcp綁定表。IPSG然後會自動在接口加載基於端口的vlan訪控(PACL)。這樣將客戶端流量限定到綁定表中所配置的源IP地址。對於來自源IP綁定之外的其他源IP地址的主機端口的流量,將會被過濾。
IP源保護只支持第2層端口,其中包括介入access和幹道trunk接口。對於不信任端口(第2層),存在以下兩種級別的IP流量安全過濾:
* 源IP地址過濾:根據源IP地址對IP流量進行過濾,只有當源IP地址與IP源綁定條目匹配,IP流量才允許通過。
當端口創建、修改、刪除新的IP源綁定條目的時候,IP源地址過濾器將發生變化。爲了能夠反映IP源綁定的變更,端口PACL將被重新修改並重新應用到端口上。
默認情況下,如果端口沒有任何IP源綁定配置的情況下啓用了ip源保護,默認的PACL將拒絕端口的所有流量。如果你取消了IP源保護,端口的ACL也會從接口上移除。
* 源IP和MAC地址過濾:根據源IP地址和MAC地址對IP流量進行過濾,只有當源IP地址和MAC地址與IP源綁定條目匹配,IP流量才允許通過。
當以IP和MAC地址作爲過濾的時候,爲了確保DHCP協議能夠正常的工作,還必須啓用DHCP監聽選項82,對於沒有選項82的數據,交換機不能確定用於轉發DHCP服務器響應的客戶端主機端口。相反地,DHCP服務器響應將被丟棄,客戶機也不能獲得ip地址
交換機使用端口安全來過濾源maC地址,所以端口上的端口安全的違規處理將關閉。
配置過程:
注意:
1. 在某個VLAN上啓用基於源IP地址的IP源保護之前,必須先啓用DHCP監聽功能
2. 如果是在TRUNK接口上對於多個VLAN啓用IP源保護,必須在所有的VLAN上啓用DHCP監聽,同時要應用基於源IP過濾策略在所有的VLAN
3. 啓用基於源ip和mac地址的IP源保護之前,必須啓用DHCP監聽和端口安全(Port security)
4. 在私有vlan上啓用基於源ip和mac地址的IP源保護,端口安全是不支持的
5. IP源保護不支持以太通道(EthenChannel)
6. 在啓用了802.x認證的情況下,也可以使用這種特性。
配置:
1) 進入全局模式    configure terminal
2) 進入接口模式    interface 接口
3) 啓用IP源保護
    基於源IP地址的      ip verify source
    基於源IP和MAC地址的    ip verify source port-security
    注意:dhcp服務器必須支持選項82,或者客戶端沒有分配到IP地址。同時MAC地址不能被學習爲安全地址
5) 進入全局模式,添加靜態的IP源綁定
    ip source binding mac地址 vlan vlan號 ip地址 interface 接口
6) 驗證結果
    show ip verify source [interface 接口]
    show ip source binding [ip地址] [mac地址] [interface 接口] [vlan vlan號] [dhcp snooping|static]
案例:
    我們接着上部分試驗繼續
Switch(config)#interface f0/2
Switch(config-if)#switchport port-security
Switch(config-if)#ip verify source port-security
Switch(config)#interface f0/3
Switch(config-if)#switchport port-security
Switch(config-if)#ip verify source port-security
Switch(config-if)#exit
Switch(config)#ip source binding 00e0.1e60.7c86 vlan 10 192.168.1.1 interface f0/1
Switch(config)#end 
Switch#show ip source bind
MacAddress       IpAddress     Lease(sec)  Type           VLAN    Interface
----------      -----------  ----------  -------------  ----  ----------------
00:10:7B:3C:01:DA   192.168.1.2   85535    dhcp-snooping  10    fastEthernet0/2
00:E0:1E:60:7C:86  192.168.1.1    infinite    static       10    fastEthernet0/1
Total number of bindings: 3
----------------------------------------------------------------
Switch#show ip verify source
Interface  Filter-type  Filter-mode  IP-address       Mac-address        Vlan
--------- ----------   -----------  ---------------  -------------  ----------
Fa0/2      ip-mac       active       192.168.1.2      permit-all         10 
Fa0/3      ip-mac       active       deny-all          permit-all         10
 
第六部分  動態ARP檢測
  DAI(Dynamic ARP Inspection)動態ARP檢測是一種能夠驗證網絡中ARP地址解析協議數據報的安全特性。通過DAI,網絡管理員能夠攔截、記錄和丟棄具有無效MAC地址/IP地址綁定的ARP數據包。
 
  如上圖,主機A、主機B、主機C連接到交換機中相同的網絡或同一個vlan中。主機A需要與主機B進行通信,主機A廣播ARP請求通過主機B的IP地址(IB)來獲得主機B的MAC地址。因爲ARP請求是以廣播的形式傳送,交換機和主機B收到主機A發出的ARP請求之後,會在自己的ARP緩存中創建或更新主機A的MAC地址(MA)和IP地址(IA),然後主機B一單播得形式發送ARP響應,交換機和主機A收到ARP響應之後,主機A將更新自己的ARP緩存,將主機B的IP地址和MAC地址對應。
  主機C破壞交換機的ARP緩存,主機C發送僞造的ARP響應(將自己的MAC地址代替真實主機的MAC地址,比如主機C用自己的MAC地址(MC)替代主機B發給主機A的MAC地址(MB)),使得主機A(或主機B)的IP地址和主機C的MAC地址(MC)對應,主機C以中間人的身份發起***。這樣造成主機A不能擁有主機B真實的MAC地址的ARP條目,同樣,主機B也認爲主機C的MAC地址是映射到主機A  IP地址的真實地址。對於主機A和主機B之間的通信,都會被髮往主機C,主機C能夠在閱讀內容後進行流量的重定向。
動態ARP檢測是一個安全特性,通過DAI,網絡管理員能夠檢測、攔截、記錄和丟棄具有無效MAC地址/IP地址綁定的ARP數據包。能夠預防“中間人”的***。
  動態ARP檢測只會轉發合法的ARP請求和響應包,他會:
* 檢測不信任的端口上的所有ARP請求和響應包
* 在更新本地的ARP緩存和轉發ARP數據包到目的地之前,會檢測是否是合法的IP和MAC地址對應內容。
* 如果確認是不合法的數據包,他會丟棄數據包並記錄這個違規的行爲。
  動態ARP檢測依據一個信任的數據庫(如手工配置或dhcp監聽綁定表)中合法的IP對應MAC地址的條目來判斷數據包的合法性。這個數據庫可以手工指定配置或者在vlan中啓用了dhcp監聽動態學習建立。如果ARP數據包是在信任端口上接收到的,交換機不會做任何檢測直接轉發ARP數據包。如果是從不信任端口上接收到ARP數據包,交換機只會轉發合法的數據包。
在DHCP服務器存在的環境下,可以在每個VLAN中啓用DHCP監聽和ip arp inspection vlan命令來啓用動態ARP檢測。如果沒有DHCP環境,用戶需要使用arp 訪問列表手工配置IP地址來啓用動態ARP檢測合法的數據包。
接口信任狀態和網絡安全
  如果ARP數據包是在信任端口上接收到的,交換機不會做任何檢測直接轉發ARP數據包。如果是從不信任端口上接收到ARP數據包,交換機只會轉發合法的數據包。
  在一個典型的網絡中,交換機中所有連接主機的端口配置爲不信任端口,所有交換機與交換機相連的端口配置爲信任端口。如下圖,交換機A和交換機B運行動態ARP檢測,主機1和主機2需要從連接到交換機A的dhcp服務器來獲得IP地址,交換機1建立主機1和主機2的IP和MAC地址的綁定信息,交換機B建立主機2的IP和MAC地址的綁定信息。如果交換機A和交換機B連接的端口設置爲不信任端口,從主機1發出的ARP數據包到達交換機B時,會被交換機B丟棄,這樣主機1和主機2的聯繫就中斷了。
 
配置過程:
默認配置:
特性             默認配置
-----------------------------------------
動態ARP檢測          所有vlan中不啓用
接口信任狀態          所有接口是不信任
進入ARP數據包流量限制  不信任端口:15 pps信任端口:沒有限制
沒有dhcp環境下的arp訪控  沒有定義
合法覈實          沒有核實允許
日誌緩衝          所有拒絕和丟棄arp數據包的行爲都會被記錄日誌的緩衝大小爲32系統信息數被限制爲5秒鐘一次
每個vlan的日誌          所有的拒絕和丟棄的行爲都被記錄
配置DHCP環境的DAI
1) 配置相應的DHCP監聽和IP源保護
2) 進入全局模式   configure terminal
3) 在指定的vlan上啓用動態ARP檢測
ip arp inspection vlan vlan範圍
4) 進入接口模式   interface 接口
5) 指定信任端口
ip arp inspection trust
6) 驗證結果
show ip arp inspection
show ip arp inspection database
show ip arp inspection vlan vlan號
show ip arp inspection statistes vlan vlan號
案例:
 
swA#config terminal
swA(config)#ip dhcp snooping
swA(config)#ip dhcp snooping vlan 10
swA(config)#ip arp inspection vlan 10
swA(config)#interface f0/1
swA(config-if)#ip dhcp snooping trust
swA(config-if)#switch access vlan 10
swA(config-if)#interface f0/2
swA(config-if)#switch access vlan 10
swA(config)#interface f0/23
swA(config-if)#ip arp inspection trust
--------------------------------------------------
swB#config terminal
swB(config)#ip dhcp snooping
swB(config)#ip dhcp snooping vlan 10
swB(config)#ip arp inspection vlan 10
swB(config-if)#interface f0/3
swB(config-if)#switch access vlan 10
swB(config)#interface f0/23
swB(config-if)#ip arp inspection trust
swB(config-if)#ip dhcp snooping trust
-----------------------------------------------------------
與交換機A fa0/1相連的路由器扮演dhcp服務器的角色
dhcpserver#conf ter
dhcpserver(config)#ip dhcp excluded-address 192.168.1.1
dhcpserver(config)#ip dhcp pool cisco
dhcpserver(dhcp-config)#network 192.168.1.0 255.255.255.0
dhcpserver(dhcp-config)#default-route 192.168.1.1
-------------------------------------------------------------
與交換機A fa0/2相連的路由器扮演主機1的角色
host1(config)#no ip routing
host1(config)#int e0
host1(config-if)#ip address dhcp
-------------------------------------------------------------
與交換機B fa0/3相連的路由器扮演主機2的角色
host2(config)#no ip routing
host2(config)#int f0/0
host2(config-if)#ip address dhcp
------------------------------------------------------------
SWA#show ip dhcp snoo bind
MacAddress      IpAddress        Lease(sec)  Type        VLAN  Interface
-------------  --------------  ----------  ----------  ----  ----------------
00:E0:1E:60:7C:86  192.168.1.2   83702     dhcp-snooping  10   FastEthernet0/2
Total number of bindings: 1
-------------------------------------------------------------------------
SWA#show ip arp inspection
Source Mac Validation      : Disabled
Destination Mac Validation : Disabled
IP Address Validation      : Disabled
 Vlan     Configuration    Operation   ACL Match          Static ACL
 ----     -------------    ---------   ---------          ----------
   10     Enabled            Active                        
 Vlan     ACL Logging      DHCP Logging
 ----     -----------      ------------
   10     Deny               Deny 
 Vlan      Forwarded        Dropped     DHCP Drops      ACL Drops
 ----      ---------        -------     ----------      ---------
   10              0              0              0              0
 Vlan   DHCP Permits    ACL Permits   Source MAC Failures
 ----   ------------    -----------   -------------------
   10              0              0                     0
 Vlan   Dest MAC Failures   IP Validation Failures   Invalid Protocol Data
 ----   -----------------   ----------------------   ---------------------
         
 Vlan   Dest MAC Failures   IP Validation Failures   Invalid Protocol Data
 ----   -----------------   ----------------------   ---------------------
   10                   0                        0                       0
------------------------------------------------------------------------
SWA#show ip arp inspection statistics vlan 10
 Vlan      Forwarded        Dropped     DHCP Drops      ACL Drops
 ----      ---------        -------     ----------      ---------
   10              0              0              0              0
 Vlan   DHCP Permits    ACL Permits   Source MAC Failures
 ----   ------------    -----------   -------------------
   10              0              0                     0
 Vlan   Dest MAC Failures   IP Validation Failures   Invalid Protocol Data
 ----   -----------------   ----------------------   ---------------------
   10                   0                        0                       0
-------------------------------------------------------------------------
SWA#show ip arp inspection inter
 Interface        Trust State     Rate (pps)    Burst Interval
 ---------------  -----------     ----------    --------------
 Fa0/1            Untrusted               15                 1
 Fa0/2            Untrusted               15                 1
 Fa0/3            Untrusted               15                 1
 Fa0/4            Untrusted               15                 1
 Fa0/5            Untrusted               15                 1
 Fa0/6            Untrusted               15                 1
 Fa0/7            Untrusted               15                 1
 Fa0/8            Untrusted               15                 1
 Fa0/9            Untrusted               15                 1
 Fa0/10           Untrusted               15                 1
 Fa0/11           Untrusted               15                 1
 Fa0/12           Untrusted               15                 1
 Fa0/13           Untrusted               15                 1
 Fa0/14           Untrusted               15                 1
 Fa0/15           Untrusted               15                 1
 Fa0/16           Untrusted               15                 1
 Fa0/17           Untrusted               15                 1
 Fa0/18           Untrusted               15                 1
 Fa0/19           Untrusted               15                 1
 Fa0/20           Untrusted               15                 1
 Fa0/21           Untrusted               15                 1
 Fa0/22           Untrusted               15                 1
 Fa0/23           Trusted               None               N/A
 Fa0/24           Untrusted               15                 1
 Gi0/1            Untrusted               15                 1
 Gi0/2            Untrusted               15                 1
 Po13             Untrusted               15                 1
 Po14             Untrusted               15                 1
--------------------------------------------------------------
SWB#show ip arp inspection vlan 10
Source Mac Validation      : Disabled
Destination Mac Validation : Disabled
IP Address Validation      : Disabled
 Vlan     Configuration    Operation   ACL Match          Static ACL
 ----     -------------    ---------   ---------          ----------
   10     Enabled          Active                        
 Vlan     ACL Logging      DHCP Logging
 ----     -----------      ------------
   10     Deny             Deny 
-------------------------------------------------------------------
SWA#show ip arp inspection statistics
 Vlan      Forwarded        Dropped     DHCP Drops      ACL Drops
 ----      ---------        -------     ----------      ---------
   10             13             45             45              0
 Vlan   DHCP Permits    ACL Permits   Source MAC Failures
 ----   ------------    -----------   -------------------
   10              1              0                     0
 Vlan   Dest MAC Failures   IP Validation Failures   Invalid Protocol Data
 ----   -----------------   ----------------------   ---------------------
   10                   0                        0                       0
-----------------------------------------------------------------------
檢測***
我們將主機2模擬爲***者,將主機2的IP地址配置爲主機1的IP地址
Rack11SW2#ping 192.168.1.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:
14:36:50: %SW_DAI-4-DHCP_SNOOPING_DENY: 1 Invalid ARPs (Req) on Fa0/3, vlan 10.([0013.1a7f.8c21/192.168.1.2/0000.0000.0000/11.11.36.6/14:36:49 UTC Mon Mar 1 1993]).
14:36:51: %SW_DAI-4-DHCP_SNOOPING_DENY: 1 Invalid ARPs (Res) on Fa0/3, vlan 10.([0013.1a7f.8c21/192.168.1.2/000d.bde6.a880/192.168.1.200/14:36:50 UTC Mon Mar 1 1993]).
14:36:55: %SW_DAI-4-DHCP_SNOOPING_DENY: 1 Invalid ARPs (Res) on Fa0/3, vlan 10.([0013.1a7f.8c21/192.168.1.2/000d.bde6.a880/192.168.1.200/14:36:54 UTC Mon Mar 1 1993]).
Success rate is 0 percent (0/5)
----------------------------------------------------------------------------
SWB#show arp
Protocol  Address          Age (min)  Hardware Addr   Type   Interface
Internet  192.168.1.2             0   Incomplete      ARPA  
配置非DHCP環境的動態ARP檢測
1) 進入全局模式  configure terminal
2) 定義arp的訪問控制列表
arp access-list 訪控名稱
3) 定義允許列表內容
permit ip host 發送者IP地址 mac host 發送者MAC地址
4) 將arp訪控應用到指定的vlan
ip arp inspection filter arp訪控名稱 vlan vlan範圍 [static]
static:使用這個參數,訪控將使用隱含的deny語句來拒絕arp數據包
5) 驗證結果
show arp access-list
案例:
 
如圖,把交換機A上相連的dhcp服務器去除,交換機B也配置了動態ARP檢測。如果我們把交換機A的端口1配置爲信任端口,因爲信任端口是不會對arp數據包做任何的檢測,這樣交換機B或者主機2對交換機A和主機1會造成arp的***。這樣交換機A的端口1配置爲非信任端口,但爲了主機2和主機1之間通信,必須在交換機A上應用一個arp訪問控制列表允許主機2訪問。如果主機2的IP地址不是靜態的,必須將交換機A和交換機B在第3層上分隔開,兩者之間添加路由器來路由兩者之間的數據包。
SwA#config terminal
SWA(config)#arp access-list cisco
SWA(config-arp-nacl)#permit ip host 192.168.1.3 mac host 0013.1a7f.8c21
SWA(config-arp-nacl)#exit
SWA(config)#int f0/23
SWA(config-if)#no ip arp inspection trust
SWA(config-if)#end
SWA(config)#ip arp inspection filter cisco vlan 10
--------------------------------------------------------------------------
SWA#show arp access-list
ARP access list cisco
permit ip host 192.168.1.3 mac host 0013.1a7f.8c21
-------------------------------------------------------------------------
SWA#show ip arp inspection
Source Mac Validation      : Disabled
Destination Mac Validation : Disabled
IP Address Validation      : Disabled
 Vlan     Configuration    Operation   ACL Match          Static ACL
 ----     -------------    ---------   ---------          ----------
   10     Enabled             Active      cisco              No
 Vlan     ACL Logging      DHCP Logging
 ----     -----------      ------------
   10     Deny             Deny 
 Vlan      Forwarded        Dropped     DHCP Drops      ACL Drops
 ----      ---------        -------     ----------      ---------
   10             21             45             45              0
 Vlan   DHCP Permits    ACL Permits   Source MAC Failures
 ----   ------------    -----------   -------------------
   10              9              0                     0
 Vlan   Dest MAC Failures   IP Validation Failures   Invalid Protocol Data
 ----   -----------------   ----------------------   ---------------------
         
 Vlan   Dest MAC Failures   IP Validation Failures   Invalid Protocol Data
 ----   -----------------   ----------------------   ---------------------
   10                   0                        0                       0
配置ARP數據包的流量限制
當進入的ARP數據包超過了配置的流量限定,交換機會將這個端口進入到err-disable狀態。這個端口一直保持這種狀態到err-disable恢復時間到期
1) 進入全局模式  configure terminal
2) 進入接口模式  interface 接口
3) 配置ARP數據包的流量限制
   ip arp inspection limit rate 每秒包數 [burst interval 秒數]
   PPS:每秒多少數據包,取值爲0-2048,非信任端口上默認爲每秒15數據包,信任端口上沒有流量限制
   Burst interval:突發時間間隔,取值爲1-15
4) 配置使能端口err-disable狀態的恢復
   errdisable recovery cause arp-inspection interval 秒數
默認情況下,err-disable恢復是關閉的,恢復時間爲300秒,取值爲30-86400
5) 驗證結果
   show ip arp inspection interface
SWA# show ip arp inspection interface f0/23
 Interface        Trust State     Rate (pps)    Burst Interval
 ---------------  -----------     ----------    --------------
 Fa0/23           Untrusted              200                 5
合法性的檢查
網絡管理員能夠根據IP對應MAC地址的綁定的合法性來攔截、記錄和丟棄具有無效MAC地址/IP地址綁定的ARP數據包。交換機能夠配置以目標的MAC地址、IP地址和源MAC地址來作爲覈實的依據。
1) 進入全局模式   configure terminal
2) 配置合法性的檢查依據
   ip arp inspection validate [src-mac|dst-mac|ip]
3) 驗證結果
SWA#show ip arp inspection statistics vlan 10
 Vlan      Forwarded        Dropped     DHCP Drops      ACL Drops
 ----      ---------        -------     ----------      ---------
   10              0              0              0              0
 Vlan   DHCP Permits    ACL Permits   Source MAC Failures
 ----   ------------    -----------   -------------------
   10              0              0                     0
 Vlan   Dest MAC Failures   IP Validation Failures   Invalid Protocol Data
 ----   -----------------   ----------------------   ---------------------
   10                   0                        0                       0
配置日誌的緩衝
1) 進入全局模式  configure terminal
2) 配置日誌緩衝
ip arp inspection log-buffer entrie 條數 | logs 數目 interval 秒數
entrie 數目:指定日誌緩衝的條目個數,取值爲0-1024
logs 數目 interval 秒數:在指定的時間間隔內,產生系統信息的條目數目
3) 指定記錄日誌的類型,默認情況下,所有拒絕和丟棄的行爲都會被記錄。
ip arp inspection vlan vlan值 logging acl-match [matchlog] | dhcp-bindings [all|none|permit]
acl-match:記錄符合arp 訪控列表條目permit或deny的內容
dhcp-bindings:記錄匹配dhcp綁定表的內容
4) 驗證結果
show ip arp inspection log
案例:
SWA(config)#ip arp inspection log-buffer entrie 15
SWA(config)#ip arp inspection log-buffer logs 100 interval 60000
SWA#show ip arp inspection log 
Total Log Buffer Size : 15
Syslog rate : 100 entries per 60000 seconds.
Interface   Vlan  Sender MAC      Sender IP    Num Pkts   Reason       Time
----------  ----  --------------  ----------  -------  -----------  ----
Fa0/3       10    0013.1a7f.8c21  192.168.1.3         1  DHCP Deny    15:59:31 UTC Mon Mar 1 1993

 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章