arp access-list static-ip
//建立ARP ACL,把分配的静态IP与相应终端设备的MAC地址进行捆绑 //把建立的ARP ACL应用到VLAN 1中
permit ip host “ip address” mac host “mac address” ip arp inspection filter static-ip vlan 1
(二) 实验步骤与记录
1. 实验环境
在“四、DHCP Snooping”实验的基础上进行,因为arp inspection是以dchp snooping为基础的。
2. arp inspection功能测试
A.
交换机配置:
Switch(config)#ip arp inspection vlan 1
Switch(config)#ip arp inspection validate src-mac ip Switch(config)#ip arp inspection log-buffer entries 1024
Switch(config)#ip arp inspection log-buffer logs 1024 interval 300 Switch(config)#errdisable recovery cause arp-inspection
Switch(config)#int g1/0/1
Switch(config-if)# ip arp inspection trust
Switch(config)#int g1/0/11
Switch(config-if)# ip arp inspection limit rate 2 B.
PC机通过DHCP自动获取IP
//限制端口每秒内通过的arp数据包为2个,默认15
//连接DHCP服务器,不设置PC虽然能获取到IP,但 //是影响正常通信,比如pc不能ping通dhcp服务器
//启用errdisable自动恢复
PC机通信正常。 C.
PC机手动更改IP
IP指定为 172.16.1.14 255.255.255.0
sh log
00:46:53: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/0/11, changed state to down 00:46:54: %LINK-3-UPDOWN: Interface GigabitEthernet1/0/11, changed state to down
00:46:57: %SW_DAI-4-DHCP_SNOOPING_DENY: 1 Invalid ARPs (Req) on Gi1/0/11, vlan 1.([d4be.d92d.1893/0.0.0.0/0000.0000.0000/172.16.1.14/00:46:56 UTC Mon Mar 1 1993])
00:46:58: %SW_DAI-4-DHCP_SNOOPING_DENY: 1 Invalid ARPs (Req) on Gi1/0/11, vlan 1.([d4be.d92d.1893/0.0.0.0/0000.0000.0000/172.16.1.14/00:46:57 UTC Mon Mar 1 1993])
00:46:58: %LINK-3-UPDOWN: Interface GigabitEthernet1/0/11, changed state to up
00:46:59: %SW_DAI-4-DHCP_SNOOPING_DENY: 1 Invalid ARPs (Req) on Gi1/0/11, vlan 1.([d4be.d92d.1893/0.0.0.0/0000.0000.0000/172.16.1.14/00:46:58 UTC Mon Mar 1 1993])
00:46:59: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/0/11, changed state to up
sh ip dhcp snooping binding
MacAddress IpAddress Lease(sec) Type VLAN Interface ------------------ --------------- ---------- ------------- ---- --------------------
D4:BE:D9:2D:18:93 172.16.1.6 infinite dhcp-snooping 1 GigabitEthernet1/0/11 Total number of bindings: 1 绑定信息没变,不是172.16.1.14。
sh ip arp inspection statistics
Vlan Forwarded Dropped DHCP Drops ACL Drops ---- --------- ------- ---------- ---------
1 0 3 3 0 Vlan DHCP Permits ACL Permits Source MAC Failures ---- ------------ ----------- -------------------
1 0 0 0 Vlan Dest MAC Failures IP Validation Failures Invalid Protocol Data ---- ----------------- ---------------------- ---------------------
1 0 0 0 丢弃的相关arp信息。
PC机状况
PC机无法通信。
Ping产生的新log
00:51:35: %SW_DAI-4-DHCP_SNOOPING_DENY: 1 Invalid ARPs (Req) on Gi1/0/11, vlan 1.([d4be.d92d.1893/172.16.1.14/0000.0000.0000/172.16.1.1/00:51:35 UTC Mon Mar 1 1993])
00:51:36: %SW_DAI-4-DHCP_SNOOPING_DENY: 1 Invalid ARPs (Req) on Gi1/0/11, vlan 1.([d4be.d92d.1893/172.16.1.14/0000.0000.0000/172.16.1.1/00:51:36 UTC Mon Mar 1 1993])
00:51:37: %SW_DAI-4-DHCP_SNOOPING_DENY: 1 Invalid ARPs (Req) on Gi1/0/11, vlan 1.([d4be.d92d.1893/172.16.1.14/0000.0000.0000/172.16.1.1/00:51:37 UTC Mon Mar 1 1993])
sh ip arp inspection statistics
Vlan Forwarded Dropped DHCP Drops ACL Drops ---- --------- ------- ---------- ---------
1 0 6 6 0 Vlan DHCP Permits ACL Permits Source MAC Failures ---- ------------ ----------- -------------------
1 0 0 0 Vlan Dest MAC Failures IP Validation Failures Invalid Protocol Data ---- ----------------- ---------------------- ---------------------
1 0 0 0 丢弃的arp又多了3条。
通过测试,可见应用了arp inspection后,终端设备通过手动指定IP,是无法进行正常通信的,也就是说,防止了用户手动指定IP的行为。
3. ip arp inspection limit rate测试
PC机自动获取IP,打开三个cmd窗口,分别同时ping 172.16.1.2、172.16.1.3、172.16.1.4,模拟arp请求速率。 log输出
01:09:50: %SW_DAI-4-PACKET_RATE_EXCEEDED: 3 packets received in 989 milliseconds on Gi1/0/11.
01:09:50: %PM-4-ERR_DISABLE: arp-inspection error detected on Gi1/0/11, putting Gi1/0/11 in err-disable state 01:09:51: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/0/11, changed state to down 01:09:52: %LINK-3-UPDOWN: Interface GigabitEthernet1/0/11, changed state to down 端口err-disable
如果PC机手动指定IP为172.16.1.14,进行同样的ping操作: log输出
01:06:03: %SW_DAI-4-DHCP_SNOOPING_DENY: 1 Invalid ARPs (Req) on Gi1/0/11, vlan 1.([d4be.d92d.1893/172.16.1.14/0000.0000.0000/172.16.1.4/01:06:02 UTC Mon Mar 1 1993])
01:06:03: %SW_DAI-4-DHCP_SNOOPING_DENY: 1 Invalid ARPs (Req) on Gi1/0/11, vlan 1.([d4be.d92d.1893/172.16.1.14/0000.0000.0000/172.16.1.3/01:06:03 UTC Mon Mar 1 1993])
01:06:03: %SW_DAI-4-PACKET_RATE_EXCEEDED: 3 packets received in 780 milliseconds on Gi1/0/11.
01:06:03: %PM-4-ERR_DISABLE: arp-inspection error detected on Gi1/0/11, putting Gi1/0/11 in err-disable state
01:06:04: %SW_DAI-4-DHCP_SNOOPING_DENY: 1 Invalid ARPs (Req) on Gi1/0/11, vlan 1.([d4be.d92d.1893/172.16.1.14/0000.0000.0000/172.16.1.4/01:06:03 UTC Mon Mar 1 1993])
01:06:04: %LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet1/0/11, changed state to down 01:06:05: %LINK-3-UPDOWN: Interface GigabitEthernet1/0/11, changed state to down
通过测试,可见ip arp inspection limit rate的设置,只是限制arp请求的速率,与是否手动指定IP无关,只有违反设定的arp请求速率,端口才会被置为err-disable状态。
4. 允许用户使用静态IP测试
A.
交换机配置:
//建立ARP ACL,把分配的静态IP与相应终端设备的MAC地址进行捆绑
Switch(config)#arp access-list static-ip Switch(config-arp-nacl)#exit
Switch(config-arp-nacl)#permit ip host 172.16.1.14 mac d4be.d92d.1893 Switch(config)#ip arp inspection filter static-ip vlan 1
//把建立的ARP ACL应用到VLAN 1中
IP为需要手动指定的动态IP,mac为PC机物理网卡对应的mac B.
测试PC机的连通性
通过以上配置,即使应用了arp inspection,也可以允许指定的mac使用指定的IP,既可以允许用户使用静态IP。
(三) 总结
在ip dhcp snooping的基础上,可以通过ip arp inspection防止用户不通过DHCP自动获取IP,而直接指定IP的行为。 在ip arp inspection限制下,如果终端设备需要使用静态IP,可以通过ip arp inspection filter来实现。
在配置dhcp snooping的基础上(需要其建立的mac与ip的binding信息): 1.
配置arp inspection基本功能:
//对指定vlan启用arp inspection //对src-mac、ip进行检查 //设置log buffer的条目数 //每3秒钟,记录10条log
Switch(config)#ip arp inspection vlan 1
Switch(config)#ip arp inspection validate src-mac ip Switch(config)#ip arp inspection log-buffer entries 1024
Switch(config)#int g1/0/1
Switch(config-if)# ip arp inspection trust
Switch(config)#ip arp inspection log-buffer logs 10 interval 3
//连接DHCP服务器,不设置PC虽然能获取到IP,但 //是影响正常通信,比如pc不能ping通dhcp服务器
//所以此端口需要设置为arp inspection信任端口
其中,对于不需要进行arp inspection的端口,需要配置成信任端口,一般非直接连接终端的端口,建议配置成信任端口。 2.
防止ARP病毒攻击:
//启用errdisable自动恢复
//限制端口每秒内通过的arp数据包为20个,默认15
Switch(config)#errdisable recovery cause arp-inspection Switch(config)#int g1/0/11
Switch(config-if)# ip arp inspection limit rate 20
通过限制通过端口的arp包的速率,可以防止arp病毒的攻击,当端口每秒接受到的arp请求超过设定数值后,相应的端口会置为err-disable状态,可以通过errdisable recovery尝试恢复端口的状态。
3.
允许用户使用静态IP:
//建立ARP ACL,把分配的静态IP与相应终端设备的MAC地址进行捆绑
Switch(config)#arp access-list static-ip Switch(config-arp-nacl)#exit
Switch(config-arp-nacl)#permit ip host 172.16.1.14 mac d4be.d92d.1893 Switch(config)#ip arp inspection filter static-ip vlan 1
//把建立的ARP ACL应用到VLAN 1中
上面的配置只是个示例,根据实际情况,使用对应的IP与MAC地址,添加需要的arp准许条目数。
百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说教育文库交换机二层增强特性实验记录(5)在线全文阅读。
相关推荐: