如图1所示,Switch作为网关通过接口GE0/0/3连接一台服务器,通过接口GE0/0/1、GE0/0/2连接VLAN10和VLAN20下的四个用户。网络中存在以下ARP威胁:
管理员希望能够防止上述ARP攻击行为,为用户提供更安全的网络环境和更稳定的网络服务。
采用如下思路在Switch上进行配置:
创建VLAN,将接口加入到VLAN中,并配置VLANIF接口
# 创建VLAN10、VLAN20和VLAN30,并将接口GE0/0/1加入VLAN10中,接口GE0/0/2加入VLAN20中,接口GE0/0/3加入VLAN30中。
system-view
[zhongwanzhi'] sysname Switch
[zhongwanzhi'] vlan batch 10 20 30
[zhongwanzhi'] interface gigabitethernet 0/0/1
[zhongwanzhi'-GigabitEthernet0/0/1] port link-type trunk
[zhongwanzhi'-GigabitEthernet0/0/1] port trunk allow-pass vlan 10
[zhongwanzhi'-GigabitEthernet0/0/1] quit
[zhongwanzhi'] interface gigabitethernet 0/0/2
[zhongwanzhi'-GigabitEthernet0/0/2] port link-type trunk
[zhongwanzhi'-GigabitEthernet0/0/2] port trunk allow-pass vlan 20
[zhongwanzhi'-GigabitEthernet0/0/2] quit
[zhongwanzhi'] interface gigabitethernet 0/0/3
[zhongwanzhi'-GigabitEthernet0/0/3] port link-type trunk
[zhongwanzhi'-GigabitEthernet0/0/3] port trunk allow-pass vlan 30
[zhongwanzhi'-GigabitEthernet0/0/3] quit
# 创建接口VLANIF10、VLANIF20、VLANIF30,配置各VLANIF接口的IP地址。
[zhongwanzhi'-Vlanif10]ip address 10.0.10.2 24
[zhongwanzhi'-Vlanif10]undo shutdown
[zhongwanzhi'-Vlanif10]quit
[zhongwanzhi']interface Vlanif 20
[zhongwanzhi'-Vlanif20]ip address 10.0.8.2 24
[zhongwanzhi'-Vlanif20]undo shutdown
[zhongwanzhi'-Vlanif20]quit
[zhongwanzhi']interface Vlanif 30
[zhongwanzhi'-Vlanif30]ip address 10.0.9.2 24
[zhongwanzhi'-Vlanif30]undo shutdown
[zhongwanzhi'-Vlanif30]quit
配置ARP表项严格学习功能
[zhongwanzhi']arp learning strict
配置ARP表项固化功能
# 配置ARP表项固化模式为fixed-mac方式。
[zhongwanzhi']arp anti-attack entry-check fixed-mac enable
配置根据源IP地址进行ARP Miss消息限速
# 配置对Server(IP地址为10.10.10.2)的ARP Miss消息进行限速,允许Switch每秒最多处理该IP地址触发的40个ARP Miss消息;对于其他用户,允许Switch每秒最多处理同一个源IP地址触发的20个ARP Miss消息。
[zhongwanzhi']arp-miss speed-limit source-ip maximum 20
[zhongwanzhi']arp-miss speed-limit source-ip 10.0.10.1 maximum 40
配置基于接口的ARP表项限制
# 配置接口GE0/0/1最多可以学习到20个动态ARP表项。
[zhongwanzhi']interface GigabitEthernet 0/0/2
[zhongwanzhi'-GigabitEthernet0/0/2]arp-limit vlan 20 maximum 20
配置根据源MAC地址进行ARP限速
# 配置对用户User1(MAC地址为1-1-1)进行ARP报文限速,每秒最多只允许10个该MAC地址的ARP报文通过。
[zhongwanzhi']arp speed-limit source-mac 1-1-1 maximum 10
配置根据源IP地址进行ARP限速
# 配置对用户User3(IP地址为10.9.9.2)进行ARP报文限速,每秒最多只允许10个该IP地址的ARP报文通过。
[zhongwanzhi']arp speed-limit source-ip 10.0.9.1 maximum 10
验证配置结果
# 执行命令display arp learning strict,可以看到全局已经配置ARP表项严格学习功能。
[zhongwanzhi']display arp learning strict
The global configuration:arp learning strict
Interface LearningStrictState
------------------------------------------------------------
------------------------------------------------------------
Total:0
Force-enable:0
Force-disable:0
# 执行命令display arp-limit,查看接口可以学习到的动态ARP表项数目的最大值。
[zhongwanzhi']display arp-limit
Interface LimitNum VlanID LearnedNum(Mainboard)
---------------------------------------------------------------------------
GigabitEthernet0/0/2 20 20 0
---------------------------------------------------------------------------
Total:1
# 执行命令display arp anti-attack configuration all,查看当前ARP防攻击配置情况。
[zhongwanzhi']display arp anti-attack configuration all
ARP anti-attack packet-check function: disable
ARP gateway-duplicate anti-attack function: disabled
ARP anti-attack log-trap-timer: 0 second(s)
(The log and trap timer of speed-limit, default is 0 and means disabled.)
ARP anti-attack entry-check mode:
Vlanif Mode
-------------------------------------------------------------------------------
All fixed-mac
-------------------------------------------------------------------------------
ARP rate-limit configuration:
-------------------------------------------------------------------------------
Global configuration:
Interface configuration:
Vlan configuration:
-------------------------------------------------------------------------------
ARP miss rate-limit configuration: