系统学习 网络工程学习路径:从分层模型与 VLAN,到路由、安全策略和设备运维

用标准/扩展 ACL 在接口和业务平面上允许或拒绝报文

适用场景

核心概念 / 常用命令或配置

标准 ACL 只匹配源地址,扩展 ACL 可匹配源/目的、协议、端口和标志位。ACL 从上到下匹配,命中即停止;Cisco 扩展 ACL 末尾有隐式 deny ip any any,Junos filter 未命中默认丢弃。方向以设备为参照:inbound 是进入接口的报文,outbound 是离开接口的报文。ACL 是无状态的,回程流量要单独放行。

把 ACL 应用到管理接口、VTY 或安全策略前,先确认不会切断 SSH/SNMP 和业务流量。保留 Console 或带外通道,Cisco 可先 reload in 10 作为保险;回滚是移除 ip access-group、traffic-filter、packet-filter 或 Junos filter 引用。不同厂商对未匹配报文的默认动作不同,以设备版本为准,并在现网实测。

Cisco IOS/IOS-XE
access-list 10 permit 192.0.2.0 0.0.0.255
access-list 100 permit tcp 192.0.2.0 0.0.0.255 host 203.0.113.10 eq 443
access-list 100 deny ip any any log
interface GigabitEthernet0/1
 ip access-group 100 in
show ip access-lists 100
Huawei VRP
acl number 3000
 rule 5 permit tcp source 192.0.2.0 0.0.0.255 destination 203.0.113.10 0 destination-port eq 443
 rule 10 deny ip
interface GigabitEthernet0/0/1
 traffic-filter inbound acl 3000
display acl 3000
H3C Comware
acl advanced 3000
 rule 5 permit tcp source 192.0.2.0 0.0.0.255 destination 203.0.113.10 0 destination-port eq 443
interface GigabitEthernet1/0/1
 packet-filter 3000 inbound
display acl 3000
Juniper Junos
set firewall family inet filter IN term 10 from source-address 192.0.2.0/24
set firewall family inet filter IN term 10 from destination-address 203.0.113.10/32
set firewall family inet filter IN term 10 from protocol tcp
set firewall family inet filter IN term 10 from destination-port 443
set firewall family inet filter IN term 10 then accept
set firewall family inet filter IN term 20 then discard
set interfaces ge-0/0/1 unit 0 family inet filter input IN

易错点

相关条目

参考链接

读完自测

合上页面,先回答,再展开对照。

  1. ACL 的 inbound 和 outbound 是相对谁定义的?
  2. 为什么只放行请求方向,返回流量可能不通?
  3. Cisco 扩展 ACL 末尾没有写 deny,未匹配报文会怎样?
答案
  1. 相对设备接口:inbound 是进入该接口,outbound 是离开该接口。
  2. ACL 是无状态的,不自动放行回程流量,返回方向需要单独规则。
  3. 会被末尾的隐式 deny ip any any 丢弃,所以规则设计要覆盖回程和必要协议。
微信小程序码:扫码打开命令速查小程序

小程序版

微信扫码,随时查命令