ACL 方向问题怎么排查
ACL 的判断基准是「报文进入接口」还是「离开接口」,所以同一条 ACL 挂在入方向能拦的流量,挂到出方向可能完全拦不到。排查第一步不是看规则内容,而是确认接口下挂了哪条 ACL、挂在哪个方向——这一步看错,后面的推演全部白费。
基本信息
| 适用设备 | 三厂通用(华为 VRP / H3C Comware / 思科 IOS) |
|---|---|
| 核对命令 | 华为/H3C display current-configuration interface ...;思科 show running-config interface ... 或 show ip interface | include access list |
| 挂载行关键字 | 华为 traffic-filter inbound|outbound acl N;思科 ip access-group N in|out;H3C packet-filter N inbound|outbound |
| 配合手段 | display acl / show ip access-lists 看命中计数 |
| 快速验证 | 把 ACL 临时挂到相反方向做对比 |
典型使用场景
- ACL 挂上了但没拦住预期的流量
- 排查过滤不生效的第一步:先确认挂载点
- 变更后评估受影响范围(同一条 ACL 被多处引用)
- 与 NAT 配合时确认过滤点位置(转换前还是转换后的地址)
- 用对调方向的排除法快速定位问题
华为 VRP
华为 VRP
display current-configuration interface GigabitEthernet0/0/1
! 看 traffic-filter inbound|outbound acl N 这一行,确认方向
display acl 3000
display acl 3000 | include rule # 规则顺序与内容思科 IOS
思科 IOS
show running-config interface GigabitEthernet0/1
show ip interface GigabitEthernet0/1 | include access list
show ip access-lists 100
show ip access-lists 100 | include matches # 命中计数定位问题H3C Comware
H3C Comware
display current-configuration interface GigabitEthernet1/0/1
! 看 packet-filter 3000 inbound|outbound
display acl 3000
display acl 3000 | include rule核对清单
| 项目 | 命令 | 看什么 |
|---|---|---|
| 接口挂载行 | display current-configuration interface / show running-config interface | 方向与 ACL 编号/名称 |
| ACL 内容 | display acl / show ip access-lists | 规则顺序与匹配条件 |
| 命中计数 | display acl 与 reset acl counter | 计数为零说明流量没走到这条规则 |
| 对比测试 | 临时挂到相反方向 | 快速确认是方向问题还是规则问题 |
| 引用台账 | 变更记录 | 同一条 ACL 的引用位置是否都清楚 |
五分钟排除法:把 ACL 临时挂到对端接口的相反方向做对比,能立刻判断是方向问题还是规则书写问题,比逐条推演配置快得多。
用于验证的临时 ACL 条目记得回收:留在现网上的调试条目一旦被忘记,会在后续故障中制造完全无法解释的现象。