配置DHCP Snooping防止DHCP Server仿冒者攻擊示例


DHCP Snooping簡介

在一次DHCP客戶端動態獲取IP地址的過程中,DHCP Snooping會對客戶端和服務器之間的DHCP報文進行分析和過濾。通過合理的配置實現對非法服務器的過濾,防止用戶端獲取到非法DHCP服務器提供的地址而無法上網。

當您的網絡中存在DHCP服務器欺騙的時候就可以考慮采用這個功能,比如:
  • 網絡中有個別終端用的是Windows Server 2003或者2008系統,默認開啟了DHCP分配IP的服務。
  • 一些接入層的端口連接有開啟了DHCP分配IP服務的無線路由器。

我們推薦在用戶接入層交換機上面部署DHCP Snooping功能,越靠近PC端口控制的越准確。而每個交換機的端口推薦只連接一台PC,否則如果交換機某端口下串接一個Hub,在Hub上連接了若干PC的話,那么如果湊巧該Hub下發生DHCP欺騙,由於欺騙報文都在Hub端口間直接轉發了,沒有受到接入層交換機的DHCP Snooping功能的控制,這樣的欺騙就無法防止了。

配置注意事項

V100R006C05版本中,S2700-SI不支持DHCP Snooping功能,其他版本所有產品均適用該示例。

組網需求

圖3-246所示,SwitchA是接入交換機,下掛的PC采用DHCP獲取IP地址。SwitchB是核心交換機,部署了DHCP服務器功能。為了防止有用戶將非法的DHCP服務器接入網絡,如自帶的無線小路由器等,導致正常用戶獲取到錯誤的地址而上不了網或者導致正常用戶獲取到沖突的地址,需要部署DHCP Snooping功能。

圖3-246 配置DHCP Snooping防止DHCP Server仿冒者攻擊組網圖

 

配置思路

采用如下思路配置DHCP Snooping:

  1. 在核心交換機SwitchB上部署DHCP服務器功能。
  2. 在接入交換機SwitchA上全局使能DHCP Snooping,然后在連接PC的接口使能DHCP Snooping,同時將上聯核心交換機的接口配置為信任接口(信任接口正常接收DHCP服務器響應的DHCP報文。另外,接入交換機只會將PC的DHCP請求報文通過信任接口發送給核心交換機)。

操作步驟

配置DHCP服務器功能。

# 在SwitchB上配置DHCP服務器功能。

<HUAWEI> system-view
[HUAWEI] sysname SwitchB
[SwitchB] vlan batch 10
[SwitchB] interface gigabitethernet 0/0/1
[SwitchB-GigabitEthernet0/0/1] port link-type trunk
[SwitchB-GigabitEthernet0/0/1] port trunk allow-pass vlan 10
[SwitchB-GigabitEthernet0/0/1] quit
[SwitchB] dhcp enable
[SwitchB] interface vlanif 10
[SwitchB-Vlanif10] ip address 10.1.1.1 255.255.255.0
[SwitchB-Vlanif10] dhcp select interface  //使能基於接口地址池分配IP地址功能
[SwitchB-Vlanif10] quit

 配置DHCP Snooping功能。

# 在SwitchA上配置DHCP Snooping功能。

<HUAWEI> system-view
[HUAWEI] sysname SwitchA
[SwitchA] vlan batch 10
[SwitchA] interface gigabitethernet 0/0/1
[SwitchA-GigabitEthernet0/0/1] port link-type trunk
[SwitchA-GigabitEthernet0/0/1] port trunk allow-pass vlan 10
[SwitchA-GigabitEthernet0/0/1] quit
[SwitchA] interface gigabitethernet 0/0/2
[SwitchA-GigabitEthernet0/0/2] port link-type access
[SwitchA-GigabitEthernet0/0/2] port default vlan 10
[SwitchA-GigabitEthernet0/0/2] quit
[SwitchA] interface gigabitethernet 0/0/3
[SwitchA-GigabitEthernet0/0/3] port link-type access
[SwitchA-GigabitEthernet0/0/3] port default vlan 10
[SwitchA-GigabitEthernet0/0/3] quit
[SwitchA] dhcp enable
[SwitchA] dhcp snooping enable ipv4  //使能全局DHCP Snooping功能並配置設備僅處理DHCPv4報文,節約設備的CPU利用率
[SwitchA] interface gigabitethernet 0/0/2
[SwitchA-GigabitEthernet0/0/2] dhcp snooping enable  //使能用戶側接口的DHCP Snooping功能
[SwitchA-GigabitEthernet0/0/2] quit
[SwitchA] interface gigabitethernet 0/0/3
[SwitchA-GigabitEthernet0/0/3] dhcp snooping enable
[SwitchA-GigabitEthernet0/0/3] quit
[SwitchA] interface gigabitethernet 0/0/1
[SwitchA-GigabitEthernet0/0/1] dhcp snooping trusted  //配置為信任接口,使得接入交換機只處理從該接口收到的DHCP服務器響應報文
[SwitchA-GigabitEthernet0/0/1] quit

 驗證配置結果
# 在SwitchA上執行命令display dhcp snooping configuration,查看DHCP Snooping的配置信息。

[SwitchA] display dhcp snooping configuration
#
dhcp snooping enable ipv4
#
interface GigabitEthernet0/0/1
 dhcp snooping trusted
#
interface GigabitEthernet0/0/2
 dhcp snooping enable
#
interface GigabitEthernet0/0/3
 dhcp snooping enable
#

 # 在SwitchB上執行命令display ip pool interface vlanif10 used,查看地址池中已經使用的IP地址信息。

[SwitchB] display ip pool interface vlanif10 used
  Pool-name      : Vlanif10
  Pool-No        : 1
  Lease          : 1 Days 0 Hours 0 Minutes
  Domain-name    : -
  DNS-server0    : -
  NBNS-server0   : -
  Netbios-type   : -
  Position       : Interface       Status           : Unlocked
  Gateway-0      : 10.1.1.1
  Network        : 10.1.1.0
  Mask           : 255.255.255.0
  VPN instance   : --

 -----------------------------------------------------------------------------
         Start           End     Total  Used  Idle(Expired)  Conflict  Disable
 -----------------------------------------------------------------------------
        10.1.1.1      10.1.1.254   253     1        252(0)         0        0
 -----------------------------------------------------------------------------
  Network section :
 -----------------------------------------------------------------------------
  Index              IP               MAC      Lease   Status
 -----------------------------------------------------------------------------
    253      10.1.1.254    0021-cccf-b67f         46   Used
 -----------------------------------------------------------------------------  

 # 在SwitchA上執行命令display dhcp snooping user-bind all,查看DHCP Snooping綁定表信息。

[SwitchA] display dhcp snooping user-bind all
DHCP Dynamic Bind-table:
Flags:O - outer vlan ,I - inner vlan ,P - Vlan-mapping
IP Address       MAC Address     VSI/VLAN(O/I/P) Interface      Lease
--------------------------------------------------------------------------------
10.1.1.254       0021-cccf-b67f  10  /--  /--    GE0/0/2        2014.09.21-09:33
--------------------------------------------------------------------------------
Print count:           1          Total count:           1                    

 后續所有PC通過DHCP獲取的IP地址只會由SwitchB進行分配。

 

配置文件

SwitchA的配置文件

#
sysname SwitchA
#
vlan batch 10
#
dhcp enable
#
dhcp snooping enable ipv4
#
interface GigabitEthernet0/0/1
 port link-type trunk
 port trunk allow-pass vlan 10
 dhcp snooping trusted
#
interface GigabitEthernet0/0/2
 port link-type access
 port default vlan 10
 dhcp snooping enable
#
interface GigabitEthernet0/0/3
 port link-type access
 port default vlan 10
 dhcp snooping enable
#
return

 SwitchB的配置文件

#
sysname SwitchB
#
vlan batch 10
#
dhcp enable
#
interface Vlanif10
 ip address 10.1.1.1 255.255.255.0
 dhcp select interface
#
interface GigabitEthernet0/0/1
 port link-type trunk
 port trunk allow-pass vlan 10
#
return

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM