环境:
DHCP服务器和PC客户端都位于vlan 10
DHCP服务器的MAC为000B.DB47.36EF,需要静态分配IP地址192.168.10.2,接在fa0/1
特殊应用服务器MAC为0016.D49F.4866,需要静态分配IP地址192.168.10.3,接在fa0/2
客户端PC的MAC为000F.1FC5.1008,通过DHCP动态获得地址,接在fa0/3
交换机为3560,Vlan 10的网关为192.168.10.1
当前相关配置如下:
ip dhcp snooping vlan 10
ip dhcp snooping
!
interface FastEthernet0/1
description : Connect to Win2003 DHCP Server
switchport access vlan 10
switchport mode access
spanning-tree portfast
ip verify source
ip dhcp snooping trust
!
interface FastEthernet0/2
switchport access vlan 10
switchport mode access
spanning-tree portfast
ip verify source
ip dhcp snooping limit rate 15
!
interface FastEthernet0/3
switchport access vlan 10
switchport mode access
spanning-tree portfast
ip verify source
ip dhcp snooping limit rate 15
!
interface Vlan10
ip address 192.168.10.1 255.255.255.0
测试步骤:
1、初始状态:交换机当前已经配置好DHCP Snooping和端口的IP Source Guard(具体配置如上所示),但还没有添加DHCP服务器和特殊应用服务器的静态源IP绑定条目;并且DHCP服务器,特殊应用服务器和客户端PC都 还没有连接到交换机,即交换机端口处于down状态
显示工作状态:
Switch#show ip dhcp snooping binding
MacAddress IpAddress Lease(sec) Type VLAN Interface
------------------ --------------- ---------- ------------- ---- --------------------
Total number of bindings: 0
当前没有任何DHCP监听绑定条目
Switch#show ip source binding
MacAddress IpAddress Lease(sec) Type VLAN Interface
------------------ --------------- ---------- ------------- ---- --------------------
Total number of bindings: 0
当前也没有任何IP源绑定条目
Switch#show ip verify source
Interface Filter-type Filter-mode IP-address Mac-address Vlan
--------- ----------- ----------- --------------- ----------------- ----------
Fa0/1 ip inactive-trust-port
Fa0/2 ip inactive-no-snooping-vlan
Fa0/3 ip inactive-no-snooping-vlan
Switch#show ip dhcp snooping binding
MacAddress IpAddress Lease(sec) Type VLAN Interface
------------------ --------------- ---------- ------------- ---- --------------------
Total number of bindings: 0
由于两台服务器都是静态指定IP地址,所以当前没有任何DHCP监听绑定条目
Switch#show ip source binding
MacAddress IpAddress Lease(sec) Type VLAN Interface
------------------ --------------- ---------- ------------- ---- --------------------
Total number of bindings: 0
//IP源绑定表没有任何条目,因为两服务器的静态IP源绑定条目还未添加
Switch#show ip verify source
Interface Filter-type Filter-mode IP-address Mac-address Vlan
--------- ----------- ----------- --------------- ----------------- ----------
Fa0/1 ip inactive-trust-port
Fa0/2 ip active deny-all 10
Fa0/3 ip inactive-no-snooping-vlan
环境:
Cisco IOS DHCP服务器(2821路由器,IOS版本为12.4)和PC客户端都位于vlan 10
路由器接在交换机的fa0/1
客户端接在fa0/2
3560交换机相关配置:
ip dhcp snooping vlan 10
ip dhcp snooping
!
interface FastEthernet0/1
description : Connect to IOS DHCP Server C2821_Gi0/0
switchport access vlan 10
switchport mode access
spanning-tree portfast
ip dhcp snooping trust
!
interface FastEthernet0/2
description : Connect to PC
switchport access vlan 10
switchport mode access switchport port-security
spanning-tree portfast ip verify source port-security
ip dhcp snooping limit rate 15
2821路由器相关配置:
ip dhcp excluded-address 192.168.10.1 192.168.10.2
!
ip dhcp pool test
network 192.168.10.0 255.255.255.0
default-router 192.168.10.1
lease 8
!
interface GigabitEthernet0/0
description : Connect to C3560_Fa0/1
ip dhcp> ip address 192.168.10.2 255.255.255.0
说明:本例中采用“源IP和源MAC地址过滤”模式,采用该模式需要注意以下三点:
(1)交换机必须对客户端的DHCP请求插入选项82信息,即必须配置ip dhcp snooping information option命令(默认即为开启)。对于没有插入选项82的DHCP请求,交换机不能确定用于转发DHCP服务器响应的客户端主机端口。相反地,DHCP 服务器响应将被丢弃,客户机也不能获得IP地址。
实验过程:通过在3560上配置no ip dhcp snooping information option命令,不再对客户端的DHCP请求插入选项82。 通过在客户端(Windows XP)上执行ipconfig /release和ipconfig /renew重新发起DHCP请求过程。结果是客户端无法获得IP地址。参考交换机上的DHCP Snooping的debug过程可以得到如下信息:
00:20:02: DHCP_SNOOPING: received new DHCP packet from input interface (FastEthernet0/1)
00:20:02: DHCP_SNOOPING: process new DHCP packet, message type: DHCPOFFER, input interface: Fa0/1, MAC da: ffff.ffff.ffff, MAC sa: 0009.b7da.f108, IP da: 255.255.255.255, IP sa: 192.168.10.2, DHCP ciaddr: 0.0.0.0, DHCP yiaddr: 192.168.10.3, DHCP siaddr: 0.0.0.0, DHCP giaddr: 0.0.0.0, DHCP chaddr: 000f.1fc5.1008
00:20:02: DHCP_SNOOPING_SW: client address lookup failed to locate client interface, retry lookup using packet mac DA: ffff.ffff.ffff
00:20:02: DHCP_SNOOPING_SW: lookup packet destination port failed to get mat entry for mac: 000f.1fc5.1008
00:20:02: DHCP_SNOOPING: can't find output interface for dhcp reply. the message is dropped.
由以上调试信息可以看出从路由器过来的DHCP回复包因为找不到目标端口而被交换机丢弃了。
(2)所使用的DHCP服务器必须支持利用DHCP选项82分配IP地址的功能,否则客户端将无法获得IP地址(debug信息类似第(1)项所述)。像 Win2003,Cisco IOS 12.2等作为DHCP服务器时都不支持利用DHCP选项82来分配IP地址。本例中如果采用12.2版本的IOS,将出现客户端无法获得IP地址的情 况。
Cisco IOS从版本12.3(4)T 开始支持利用选项82分配IP地址。 最简单的方法,看IOS是否支持命令ip dhcp use> 可以尝试在交换机上开启 DHCP Snooping 的 debug 过程,查看收到的 DHCP Offer 消息中有没有DHCP选项82信息的调试数据。如:
00:10:41: DHCP_SNOOPING: received new DHCP packet from input interface (FastEthernet0/1)
00:10:41: DHCP_SNOOPING: process new DHCP packet, message type: DHCPOFFER, input interface: Fa0/1, MAC da: 000f.1fc5.1008, MAC sa: 0019.e765.d3b0, IP da: 192.168.10.3, IP sa: 192.168.10.2, DHCP ciaddr: 0.0.0.0, DHCP yiaddr: 192.168.10.3, DHCP siaddr: 0.0.0.0, DHCP giaddr: 0.0.0.0, DHCP chaddr: 000f.1fc5.1008
00:10:41: DHCP_SNOOPING: binary dump of option 82, length: 20 data:0x52 0x12 0x1 0x6 0x0 0x4 0x0 0xA 0x0 0x2 0x2 0x8 0x0 0x6 0x0 0x12 0xDA 0x88 0x88 0x0
00:10:41: DHCP_SNOOPING: binary dump of extracted circuit>
00:10:41: DHCP_SNOOPING: binary dump of extracted remote> 00:10:41: DHCP_SNOOPING_SW: opt82 data indicates local packet