前面的文章中我们也讲解过dhcp snooping的有关知识,对于它的理解,配置以及相关的调制,应用我们都介绍过了。这里我们再来对IP dhcp snooping的具体配置以及案例分析进行一下介绍,希望对大家能够有所帮助。
1、3750配置DHCP服务,配置DHCP snooping
- 如下:(无用的部分已经删除了)
- clock timezone WST 8
- switch 1 provision ws-c3750g-48ts
- system mtu routing 1500
- ip subnet-zero
- ip dhcp excluded-address 192.168.1.1 (保留地址)
- !
- ip dhcp pool test (启动DHCP)
- network 192.168.1.0 255.255.255.0
- default-router 192.168.1.1
- dns-server 192.168.1.1
- !
- ip dhcp snooping vlan 1 (指定DHCP snooping防护的vlan)
- ip dhcp snooping information option allow-untrusted
- ip dhcp snooping database flash:snooping (指定数据库路径)
- ip dhcp snooping (启动DHCP snooping)
- !
- !
- interface GigabitEthernet1/0/1
- !
- interface GigabitEthernet1/0/31 (正常的端口)
- switchport mode access
- spanning-tree portfast
- !
- interface GigabitEthernet1/0/32
- !
- interface GigabitEthernet1/0/42
- !
- interface GigabitEthernet1/0/43 (启用IP DHCP snooping端口)
- switchport mode access
- switchport port-security
- spanning-tree portfast
- ip verify source
(启用IP地址效验,此端口用户不能自己设置地址,只能通过DHCP获得,但没有mac层安全控制。
测试发现,假如g1/0/43口的用户分得地址=192.168.1.2,g1/0/42用户故意修改IP为192.168.1.2,也会影响 g1/0/43的用户,虽然g1/0/42修改IP不能访问网络,但g1/0/43会提示IP冲突,所以必须结合DAI才能保护mac层)
- !
- interface GigabitEthernet1/0/44
- !
- interface GigabitEthernet1/0/45
- switchport mode access
- switchport port-security
- switchport port-security violation restrict
- spanning-tree portfast
- ip verify source port-security
- (启用后此端口无法DHCP注册地址,分析原因由于port-security的安全限制无法注册MAC)
- (ip verify source port-security是配合启动IP soure binding使用
- ip source binding 001b.a111.5e11 vlan 1 192.168.1.200 interface Gi1/0/45,注意ip source binding和动态DHCP不能同时用)
- !
- interface GigabitEthernet1/0/46
- !
#p#2、静态IP dhcp snooping和IP Source Guard
- clock timezone WST 8
- switch 1 provision ws-c3750g-48ts
- system mtu routing 1500
- ip subnet-zero
- !
- ip dhcp snooping vlan 1 (指定DHCP snooping防护的vlan)
- ip dhcp snooping information option allow-untrusted
- ip dhcp snooping database flash:snooping (指定数据库路径)
- ip dhcp snooping database write-delay 15
- ip dhcp snooping (启动DHCP snooping)
- !
- !
- !
- interface GigabitEthernet1/0/45 (启动IP Source Guard的端口)
- switchport mode access
- switchport port-security
- switchport port-security violation restrict
- spanning-tree portfast
- ip verify source port-security
- (ip verify source port-security是配合启动IP soure binding使用
- ip source binding 000A.E439.5F55 vlan 1 192.168.1.200 interface Gi1/0/45,说明ip source binding和动态DHCP不能同时用)
- !
- !
- interface Vlan1
- ip address 192.168.1.1 255.255.255.0
- !
- ip classless
- ip http server
- ip http secure-server
- !
- !
- ip source binding 000A.E439.5F55 vlan 1 192.168.1.200 interface Gi1/0/45
- !
- control-plane
- !
- !
- 注意使用如下命令查看工作状态:
- Switch#sh ip ver source
- Switch#sh ip dhcp binding
- Switch#sh ip dhcp snooping binding
#p#3、启动dai
- ip subnet-zero
- ip dhcp excluded-address 192.168.1.1
- !
- ip dhcp pool test
- network 192.168.1.0 255.255.255.0
- default-router 192.168.1.1
- dns-server 192.168.1.1
- lease infinite
- !
- ip dhcp snooping vlan 1 (需要DHCP为基础)
- ip dhcp snooping information option allow-untrusted
- ip dhcp snooping database flash:snooping(指定snooping 数据保存位置)
- ip dhcp snooping (启动DHCP snooping)
- ip arp inspection vlan 1 (启动DAI)
- ip arp inspection validate src-mac dst-mac ip (检测项目)
- !
- !
- !
- interface GigabitEthernet1/0/31
- switchport mode access
- ip arp inspection trust (如果设置trust可以改IP,设置untrust不可以改IP,因为DAI检测)
- spanning-tree portfast
- !
- interface GigabitEthernet1/0/32
- !
- nterface GigabitEthernet1/0/44
- !
- interface GigabitEthernet1/0/45
- switchport mode access
- switchport port-security
- switchport port-security violation restrict
- spanning-tree portfast
- ip verify source port-security
- !
- !
- Switch#sh ip arp inspection
#p#4、DHCP设置,分配固定IP
有时我们需要控制IP分配,可以使用下面方法!
- system mtu routing 1500
- ip subnet-zero
- ip dhcp excluded-address 192.168.1.1
- !
- ip dhcp pool test
- host 192.168.1.18 255.255.255.0 (分给用户的IP)
- client-identifier 0101.0bf5.395e.55(用户端mac)
- client-name test
- !
- ip dhcp pool go
- network 192.168.1.0 255.255.255.0 (启动网内DHCP)
- !
- Switch#sh ip dhcp binding
- IP address Client-ID/ Lease expiration Type
- Hardware address
- 192.168.1.18 0101.0bf5.395e.55 Infinite Manual
时间仓促,没能进行很好的测试,希望大家能够讨论,给与指正!