环境:2611路由器作为DHCP服务器,IP地址为192.168.2.2,位于vlan 2;PC位于vlan 10;
路由器接在3560的Gi0/2,PC接2960的fa0/1口,两交换机互连口都是gi0/1
3560交换机相关配置:
ip routing
!
interface GigabitEthernet0/1
description : Connect to C2960_Gi0/1
switchport trunk encapsulation dot1q
switchport mode trunk
!
interface GigabitEthernet0/2
description : Connect to IOS DHCP Server C2611_Gi0/0
switchport access vlan 2
switchport mode access
spanning-tree portfast
!
interface Vlan2
ip address 192.168.2.1 255.255.255.0
!
PC
CIisco IOS 3560 2960
DHCP Server
interface Vlan10
ip address 192.168.10.1 255.255.255.0
ip helper-address 192.168.2.2
ip dhcp relay information trusted
2960交换机相关配置:
ip dhcp snooping vlan 10
ip dhcp snooping
interface FastEthernet0/1
description : Connect to PC
switchport access vlan 10
switchport mode access
spanning-tree portfast
ip dhcp snooping limit rate 15
!
interface GigabitEthernet0/1
description : Connect to C3560_Gi0/1
switchport mode trunk
ip dhcp snooping trust
2611路由器相关配置:
no ip routing
!
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_Gi0/2
ip address 192.168.2.2 255.255.255.0
!
ip default-gateway 192.168.2.1
说明:本例中3560没有开启DHCP监听功能,2960开启了该功能。需要注意的是int vlan 10需要配置ip
dhcp relay information trusted,理由如同实例2。
5、多交换机环境(DHCP服务器和DHCP客户端位于同一VLAN)
环境:3560交换机自身作为DHCP服务器;PC1和PC2都位于vlan 10;
PC1接3560的fa0/1口,PC2接2960的fa0/1口;两交换机互连口都是gi0/1
3560交换机相关配置:
ip dhcp excluded-address 192.168.10.1
!
ip dhcp pool test
network 192.168.10.0 255.255.255.0
default-router 192.168.10.1
lease 8
!
ip dhcp snooping vlan 10
ip dhcp snooping information option allow-untrusted
ip dhcp snooping
!
interface FastEthernet0/1
description : Connect to PC1
switchport access vlan 10
switchport mode access
spanning-tree portfast
ip dhcp snooping limit rate 15
!
interface GigabitEthernet0/1
description : Connect to C2960_Gi0/1
switchport trunk encapsulation dot1q
switchport mode trunk
ip dhcp snooping limit rate 360
2960交换机相关配置:
ip dhcp snooping vlan 10
ip dhcp snooping
interface FastEthernet0/1
description : Connect to PC2
switchport access vlan 10
switchport mode access
spanning-tree portfast
ip dhcp snooping limit rate 15
PC1
PC2
3560
2960
!
interface GigabitEthernet0/1
description : Connect to C3560_Gi0/1
switchport mode trunk
ip dhcp snooping trust
说明:本例中3560和2960同时开启了DHCP监听功能。从2960过来的DHCP请求报文是已经被插入了选
项82信息,如果将3560的Gi0/1设置为信任端口,那么插入了82选项的DHCP请求报文是允许通过的,
但不会为其建立DHCP监听绑定表。即3560上只有PC1的绑定条目,而没有PC2的绑定条目。
如果此时同时部署DAI,IPSG,由于2960不支持这两项功能,对于3560来说,从2960上过来的数
据可能存在IP欺骗和ARP欺骗等攻击,是不安全的。另一方面,由于3560没有PC2的绑定条目,而DAI
和IPSG必须依赖DHCP监听绑定表。因此如果需要在3560上再部署DAI或者IPSG,就不能将3560的
Gi0/1设置为信任端口。
但是将3560的Gi0/1口设置为非信任端口以后,默认情况下,非信任端口将会丢弃收到的插入了82
选项的DHCP请求报文。而从2960过来的DHCP请求报文又正好是被插入了选项82信息的。因此必须配
置ip dhcp snooping information option allow-untrusted命令,否则3560将丢弃这些DHCP请求报文,接在
2960上的PC2将得不到IP地址。只有配置了该命令以后,3560才会接收从2960发送的插入了选项82的
DHCP报文,并为这些信息建立绑定条目。
3560下联的Gi0/1口由于是非信任端口,默认限速为每秒15个DHCP请求报文,如果2960上的所有
PC都同时发起DHCP请求,可能此端口会被errdisable掉。这里假设2960为24口,因此简单的设置限速
为24*15=360。
2960上联的Gi0/1口必须被配置为信任端口,否则将丢弃从3560过来的DHCP应答报文,PC2将无
法得到IP地址。
C3560#show ip dhcp snooping
Switch DHCP snooping is enabled
DHCP snooping is configured on following VLANs:
10
DHCP snooping is operational on following VLANs:
10
DHCP snooping is configured on the following L3 Interfaces:
Insertion of option 82 is enabled
circuit-id format: vlan-mod-port
remote-id format: MAC
Option 82 on untrusted port is allowed
Verification of hwaddr field is enabled
DHCP snooping trust/rate is configured on the following Interfaces:
Interface Trusted Rate limit (pps)
------------------------ ------- ----------------
FastEthernet0/1 no 15
GigabitEthernet0/1 no 360
C3560#show ip dhcp snooping binding
MacAddress IpAddress Lease(sec) Type VLAN Interface
------------------ --------------- ---------- ------------- ---- --------------------
00:0F:1F:C5:10:08 192.168.10.2 685618 dhcp-snooping 10 FastEthernet0/1
00:0B:DB:08:21:E0 192.168.10.3 688023 dhcp-snooping 10 GigabitEthernet0/1
C2960#show ip dhcp snooping
Switch DHCP snooping is enabled
DHCP snooping is configured on following VLANs:
10
Insertion of option 82 is enabled
circuit-id format: vlan-mod-port
remote-id format: MAC
Option 82 on untrusted port is not allowed
Verification of hwaddr field is enabled
Interface Trusted Rate limit (pps)
------------------------ ------- ----------------
FastEthernet0/1 no 15
GigabitEthernet0/1 yes unlimited
C2960#show ip dhcp snooping binding
MacAddress IpAddress Lease(sec) Type VLAN I nterface
------------------ --------------- ---------- ------------- ---- --------------------
00:0B:DB:08:21:E0 192.168.10.3 688023 dhcp-snooping 10 FastEthernet0/1
6、多交换机环境(DHCP服务器和DHCP客户端位于同一VLAN)
环境:4503交换机自身作为DHCP服务器;PC1和PC2都位于vlan 10;
PC1接4503的gi2/1口,PC2接3560的fa0/1口;两交换机互连口是4503 gi1/1 -- 3560 gi0/1
4503交换机相关配置:
ip dhcp excluded-address 192.168.10.1
!
ip dhcp pool test
network 192.168.10.0 255.255.255.0
default-router 192.168.10.1
lease 8
!
ip dhcp snooping vlan 10
ip dhcp snooping
!
interface GigabitEthernet2/1
PC1
PC2
4503
3560
description : Connect to PC1
switchport access vlan 10
switchport mode access
spanning-tree portfast
ip dhcp snooping limit rate 15
!
interface GigabitEthernet1/1
description : Connect to C3560_Gi0/1
switchport trunk encapsulation dot1q
switchport mode trunk
ip dhcp snooping trust
3560交换机相关配置:
ip dhcp snooping vlan 10
ip dhcp snooping
interface FastEthernet0/1
description : Connect to PC2
switchport access vlan 10
switchport mode access
spanning-tree portfast
ip dhcp snooping limit rate 15
!
interface GigabitEthernet0/1
description : Connect to C4503_Gi1/1
switchport trunk encapsulation dot1q
switchport mode trunk
ip dhcp snooping trust
说明:本例中4503和3560同时开启了DHCP监听功能。由于4503的下联口被设置为信任端口,所以从
3560过来的DHCP请求报文即使已经被插入了选项82信息,也允许通过的,但不会为其建立DHCP监听
绑定表。所以4503上只有PC1的绑定条目,而没有PC2的绑定条目。
作为接入层交换机的3560支持DAI,IPSG,如果同时配置这两项功能,那么有理由相信从3560过
来的数据是已经经过检验的安全数据,因此将4503的下联口设置为信任端口是可行的。另外,4503没有
PC2的绑定条目,也减少了系统运行时所需的内存空间。
C4503#show ip dhcp snooping binding
MacAddress I pAddress Lease(sec) Type VLAN Interface
------------------ --------------- ---------- ------------- ---- --------------------
00:0F:1F:C5:10:08 192.168.10.2 685618 dhcp-snooping 10 GigabitEthernet2/1
C3560#show ip dhcp snooping binding
MacAddress IpAddress Lease(sec) Type VLAN Interface
------------------ --------------- ---------- ------------- ---- --------------------
00:0B:DB:08:21:E0 192.168.10.3 688023 dhcp-snooping 10 FastEthernet0/1