实验 18 配置动态 ARP 检测
组名:C组
组长:程达
组员:陈婉丽 张佳莉 张文倩 张青 邢留洋 郝亚磊
【实验名称】
配置动态ARP检测。
【实验目的】
使用交换机的DAI功能增强网络安全性。
【背景描述】
某企业的网络管理员发现最近经常有员工抱怨无法访问互联网,经过故障排查后,发现客
户端PC上缓存网关的ARP绑定条目是错误的,从该现象可以判断网络中可能出现了ARP欺
骗攻击,导致客户端PC不能获取正确的ARP条目,以至不能够访问外部网络。
如果通过交换机的ARP检查功能解决此问题,需要在每个接入端口上配置地址绑定,工作
量过大,因此考虑用DAI功能来解决ARP欺骗攻击的问题。
【需求分析】
ARP欺骗攻击是目前内部网络中出现最频繁的一种攻击。对于这种攻击,需要检查网络中
ARP报文的合法性。交换机的DAI功能可以满足这个要求,防止ARP欺骗攻击。
【实验拓扑】
实验的拓扑图,如图18-1所示。
图18-1
【实验设备】
二层交换机1台(支持DHCP监听与DAI)
三层交换机1台(支持DHCP监听与DAI)
PC机3台(其中1台需安装DHCP服务器,另1台安装ARP欺骗攻击工具WinArpSpoofer
(测试用))
【预备知识】
交换机转发原理、交换机基本配置、DHCP监听原理、DAI原理、ARP欺骗原理。
【实验原理】
交换机的DAI功能可以检查端口收到的ARP报文的合法性,并可以丢弃非法的ARP报文,
防止ARP欺骗攻击。
【实验步骤】
步骤1 配置DHCP服务器。
将1台PC配置为DHCP服务器,可以使用Windows Server配置DHCP服务器,或者使用
第三方DHCP服务器软件。DHCP服务器中的地址池为172.16.1.0/24。
步骤2 SW2基本配置及DHCP监听配置(接入层)。
Switch#configure
Switch(config)#hostname SW2
SW2 (config)#vlan 2
SW2 (config-vlan)#exit
SW2 (config)#interface range fastEthernet 0/1-2
SW2 (config-if-range)#switchport access vlan 2
SW2 (config-if-range)#exit
SW2 (config)#interface fastEthernet 0/24
SW2 (config-if)#switchport mode trunk
SW2 (config-if)#exit
SW2 (config)#ip dhcp snooping
SW2 (config)#interface fastEthernet 0/24
SW2 (config-if)#ip dhcp snooping trust
SW2 (config-if)#end
SW2#
步骤3 SW1基本配置、DHCP监听配置及DHCP Relay配置(分布层)。
Switch#configure
Switch (config)#hostname SW1
SW1 (config)#interface fastEthernet 0/24
SW1 (config-if)#switchport mode trunk
SW1 (config-if)#exit
SW1 (config)#vlan 2
SW1 (config-vlan)#exit
SW1 (config)#interface vlan 2
SW1 (config-if)#ip address 172.16.1.1 255.255.255.0
SW1 (config-if)#exit
SW1 (config)#vlan 100
SW1 (config-vlan)#exit
SW1 (config)#interface vlan 100
SW1 (config-if)#ip address 10.1.1.2 255.255.255.0
SW1 (config-if)#exit
SW1 (config)#interface fastEthernet 0/1
SW1 (config-if)#switchport access vlan 100
SW1 (config-if)#exit
SW1 (config)#ip dhcp snooping
!启用DHCP snooping功能
SW1 (config)#interface fastEthernet 0/1
SW1 (config-if)#ip dhcp snooping trust
!配置F0/1端口为trust端口
SW1 (config-if)#exit
SW1 (config)#interface fastEthernet 0/24
SW1 (config-if)#ip dhcp snooping trust
!配置F0/24端口为trust端口
SW1 (config-if)#exit
SW1 (config)#service dhcp
SW1 (config)#ip helper-address 10.1.1.1
!配置DHCP中继,指明DHCP服务器地址
SW1 (config)#end
SW1#
步骤4 验证测试。
确保DHCP服务器可以正常工作。将客户端PC1和PC2(攻击机)配置为自动获取地址后,
接入交换机端口,此时可以看到从DHCP服务器获得了地址。
PC1地址配置信息,获取地址为172.16.1.2,如图18-2所示。
图18-2
PC2地址配置信息,获取地址为172.16.1.3,如图18-3所示。
图18-3
在SW2上查看DHCP监听绑定信息。
SW2#show ip dhcp snooping binding
Total number of bindings: 2
MacAddress IpAddress Lease(sec) Type VLAN Interface
------------------ --------------------- ----- --------------------
0015.f2dc.96a4 172.16.1.279364 dhcp-snooping 2 FastEthernet 0/1
0016.d393.22c6 172.16.1.385420 dhcp-snooping 2 FastEthernet 0/2
步骤5 验证测试。
使用ping命令验证设备之间的连通性,保证可以互通。查看PC1机本地的ARP缓存,ARP
表中存有正确的网关IP与MAC地址绑定,如图18-4所示。
图18-4
步骤6 在攻击机上运行WinArpSpoofer软件后,界面如图18-5所示。
图18-5
在“Adapter”页面中,选择正确的网卡后,WinArpSpoofer会显示网卡的IP地址、掩码、
网关、MAC地址以及网关的MAC地址信息。
步骤7 在WinArpSpoofer界面中选择“Spoofing”标签,打开“Spoofing”选项卡,如图
18-6所示。
图18-6
在“Spoofing”页面中,取消选中“Act as a Router(or Gateway)while spoofing.”选项。
如果选中,软件还将进行ARP中间人攻击。配置完毕后,单击“OK”按钮。
步骤8 使用WinArpSpoofer进行扫描。
单击工具栏中的“Scan”按钮,软件将会扫描网络中的主机,并获取其IP地址、MAC地
址等信息,如图18-7所示。
图18-7
步骤9 进行ARP欺骗。
单击工具栏中的“Star”按钮,软件将进行ARP欺骗攻击,如图18-8所示。
图18-8
步骤10 验证测试。
通过使用Ethereal捕获攻击机发出的报文,可以看出攻击机发送了经过伪造的ARP应答
(Reply)报文,目的MAC地址为PC1的MAC地址(0016.d393.22c6)。攻击者“声称”网关
(IP地址为172.16.1.1)的MAC地址为自己的MAC地址(0015.f2dC.96a4),并“声称”自己
(IP地址为172.16.1.2)的MAC地址为网关的MAC地址(00d0.f821.a543)。
图18-9
步骤11 验证测试。
使用PC1 ping网关的地址,发现无法ping同。查看PC1的ARP缓存,可以看到PC1收到
了伪造的ARP应答报文后,更新了ARP表,表中的条目为错误的绑定,即网关的IP地址与攻
击机的MAC地址进行了绑定,如图18-10所示。
图18-10
步骤12 配置DAI。
在SW2上对于VLAN 2配置DAI,防止VLAN 2中的主机进行ARP欺骗。
SW2#configure
SW2 (config)#ip arp inspection
SW2 (config)#ip arp inspection vlan 2
!在VLAN2上启用DAI
SW2 (config)#interface f0/24
SW2 (config-if)#ip arp inspection trust
!配置F0/24端口为监控信任端口
SW2 (config-if)#end
SW2#
步骤12 验证测试。
启用ARP检查功能后,当交换机端口收到非法ARP报文,会将其丢弃。这时在PC机上
查看ARP缓存,发现ARP表中的条目是正确的,并且PC1可以ping通网关。(注意:由于PC
机之前缓存了错误的ARP条目,所以需要等到错误条目超时或者使用arp –d命令进行手动删
除之后,PC1才能解析出正确的网关MAC地址),如图18-11所示。
图18-11
【注意事项】
? DHCP监听只能配置在物理端口上,不能配置在VLAN接口上。
? DAI只能配置在物理端口上,不能配置在VLAN接口上。
? 如果端口所属的VLAN启用了DAI,并且为Untrust端口,当端口收到ARP报文后,
若查找不到DHCP监听表项,则丢弃ARP报文,造成网络中断。
? WinArpSpoofer软件仅可用于实验。
【参考配置】
SW1#show running-config
Building configuration...
Current configuration : 1427 bytes
!
hostname SW1
!
!
!
vlan 1
!
vlan 2
!
vlan 100
!
!
service dhcp
ip helper-address 10.1.1.1
ip dhcp snooping
!
!
!
!
interface FastEthernet 0/1
switchport access vlan 100
ip dhcp snooping trust
!
interface FastEthernet 0/2
!
interface FastEthernet 0/3
!
interface FastEthernet 0/4
!
interface FastEthernet 0/5
!
interface FastEthernet 0/6
!
interface FastEthernet 0/7
!
interface FastEthernet 0/8
!
interface FastEthernet 0/9
!
interface FastEthernet 0/10
!
interface FastEthernet 0/11
!
interface FastEthernet 0/12
!
interface FastEthernet 0/13
!
interface FastEthernet 0/14
!
interface FastEthernet 0/15
!
interface FastEthernet 0/16
!
interface FastEthernet 0/17
!
interface FastEthernet 0/18
!
interface FastEthernet 0/19
!
interface FastEthernet 0/20
!
interface FastEthernet 0/21
!
interface FastEthernet 0/22
!
interface FastEthernet 0/23
!
interface FastEthernet 0/24
switchport mode trunk
ip dhcp snooping trust
!
interface GigabitEthernet 0/25
!
interface GigabitEthernet 0/26
!
interface GigabitEthernet 0/27
!
interface GigabitEthernet 0/28
!
interface VLAN 2
ip address 172.16.1.1 255.255.255.0
!
interface VLAN 100
ip address 10.1.1.2 255.255.255.0
!
!
!
!
!
line con 0
line vty 0 4
login
!
!
end
SW2#show running-config
Building configuration...
Current configuration : 1325 bytes
!
hostname SW2
!
!
!
vlan 1
!
vlan 2
!
!
ip dhcp snooping
!
!
!
!
!
!
!
!
ip arp inspection vlan 2
ip arp inspection
!
!
!
!
!
interface FastEthernet 0/1
switchport access vlan 2
!
interface FastEthernet 0/2
switchport access vlan 2
!
interface FastEthernet 0/3
!
interface FastEthernet 0/4
!
interface FastEthernet 0/5
!
interface FastEthernet 0/6
!
interface FastEthernet 0/7
!
interface FastEthernet 0/8
!
interface FastEthernet 0/9
!
interface FastEthernet 0/10
!
interface FastEthernet 0/11
!
interface FastEthernet 0/12
!
interface FastEthernet 0/13
!
interface FastEthernet 0/14
!
interface FastEthernet 0/15
!
interface FastEthernet 0/16
!
interface FastEthernet 0/17
!
interface FastEthernet 0/18
!
interface FastEthernet 0/19
!
interface FastEthernet 0/20
!
interface FastEthernet 0/21
!
interface FastEthernet 0/22
!
interface FastEthernet 0/23
!
interface FastEthernet 0/24
switchport mode trunk
ip arp inspection trust
ip dhcp snooping trust
!
interface GigabitEthernet 0/25
!
interface GigabitEthernet 0/26
!
interface GigabitEthernet 0/27
!
interface GigabitEthernet 0/28
!
!
!
!
!
line con 0
line vty 0 4
login
!
!
end