DHCP都非常熟悉了,对于DHCP客户端而言,初始过程中都是通过发送广播的DHCPdiscovery消息寻找DHCP服务器,然而这时候如果内网中存在私设的DHCP服务器,那么就会对网络造成影响,例如客户端通过私设的DHCP服务器拿到一个非法的地址,最终导致PC无法上网。
配置示例
PC属于VLAN10,网关在SW2上。DHCPserver属于VLAN100,网关在SW2上。
SW1为接入层交换机,部署DHCP snooping,将Fa0/24定义为trust接口。
SW2为核心层交换机,部署DHCP relay
DHCPserver的配置如下:
no ip routing
ip default-gateway 192.168.100.254
Interface fast0/0
ip address 192.168.100.1255.255.255.0
no shutdown
exit
Service dhcp
Ip dhcp pool vlan10
network 192.168.10.0 /24
default-router 192.168.10.254
SW1的配置如下:
vlan 10
!
ip dhcp snooping !! 全局开启DHCPsnooping
ip dhcp snooping vlan 10 !!vlan10激活DHCP snooping
no ip dhcp snooping informationoption !!不写入option82
!
Interface fast0/1
switchport access vlan 10
interface fast0/24
switchport trunk encapsulation dot1q
switchport mode trunk
ip dhcp snoopingtrust
SW2的配置如下:
vlan 10
vlan 100
name Server
!
Interface fast0/1
switchport access vlan 100
interface fast0/24
switchport trunk encapsulation dot1q
switchport mode trunk
Interface vlan 10
ip address 192.168.10.254255.255.255.0
ip helper-address 192.168.100.1
Interface vlan 100
ip address 192.168.100.254255.255.255.0
实验结果:
PC获取到了地址,在SW1上查看dhcp snooping bingding databsae:
SW1#show ip dhcp snoopingbinding
MacAddress ipAddress Lease(sec) Type VLAN Interface
------ --------------- ---------- ---------- ---- -------------------
00:B0:64:04:09:99 192.168.10.1 86025 dhcp-snooping 10 FastEthernet0/1
Total number of bindings: 1
http://blog.sina.com.cn/s/blog_5ec353710101dy03.html
>>假如说原先还有一台PC2也是接在SW1的另一个端口上,而且PC2就是一台非法的DHCP server,PC1在已经从PC2那边获得非正常的IP之后,我们再去做DHCP snooping 设置, dhcp snooping 是不会立即生效的,即使把PC1的网络连接禁用再启用