配置基于时间段的ACL需要三个核心步骤:定义时间段、配置ACL规则、应用ACL策略。以下是详细说明及四大厂商配置对比:
定义时间段 创建时间范围(如工作日8:30-17:30),支持绝对时间(某日期范围)和周期时间(每周重复)。
配置ACL规则 在ACL中引用时间段,设置允许/拒绝规则。例如:
# 示例:允许192.168.1.0/24在工作日访问80端口
rule permit tcp source 192.168.1.0 0.0.0.255 destination-port eq 80 time-range WORKTIME
应用ACL策略 将ACL绑定到接口或流策略实现流量过滤[5][8]。
功能 | 思科(Cisco) | 华为(Huawei) | 华三(H3C) | 锐捷(Ruijie) |
---|---|---|---|---|
时间段定义命令 | time-range WORKTIME periodic weekly Mon-Fri 8:30 to 17:30 | time-range WORKTIME 8:30 to 17:30 working-day | time-range WORKTIME 8:30 to 17:30 working-day | time-range WORKTIME 8:30 to 17:30 daily |
ACL引用时间段格式 | access-list 101 permit tcp any any eq 80 time-range WORKTIME | rule permit tcp source any destination any destination-port eq 80 time-range WORKTIME | rule permit tcp source any destination any destination-port eq 80 time-range WORKTIME | rule permit tcp any any eq www time-range WORKTIME |
接口应用命令 | interface g0/1; ip access-group 101 in | interface g0/0/1; traffic-filter inbound acl 3000 | interface g1/0/1; packet-filter 3000 inbound | interface g0/1; ip access-group 101 in |
时间段类型支持 | 绝对时间+周期时间 | 绝对时间+周期时间 | 绝对时间+周期时间 | 绝对时间+周期时间 |
时间格式 | 24小时制(HH:MM) | 24小时制(HH:MM) | 24小时制(HH:MM) | 24小时制(HH:MM) |
! 定义时间段
time-range WORKTIME
periodic weekly Mon-Fri 8:30 to 17:30
! 配置ACL
ip access-list extended TIMED-ACL
permit tcp 192.168.1.0 0.0.0.255 any eq 80 time-range WORKTIME
deny tcp any any eq 8001 time-range WORKTIME
! 应用ACL到接口
interface GigabitEthernet0/1
ip access-group TIMED-ACL in
# 定义时间段
time-range WORKTIME 08:30 to 17:30 working-day
# 配置ACL
acl number 3000
rule 5 permit tcp source 192.168.1.0 0.0.0.255 destination-port eq www time-range WORKTIME
rule 10 deny tcp destination-port eq 8001 time-range WORKTIME
# 应用ACL到接口
interface GigabitEthernet0/0/1
traffic-filter inbound acl 3000
# 定义时间段
time-range WORKTIME 08:30 to 17:30 working-day
# 配置ACL
acl advanced 3000
rule 5 permit tcp source 192.168.1.0 0.0.0.255 destination-port eq www time-range WORKTIME
rule 10 deny tcp destination-port eq 8001 time-range WORKTIME
# 应用ACL到接口
interface GigabitEthernet1/0/1
packet-filter 3000 inbound
! 定义时间段
time-range WORKTIME daily 8:30 to 17:30
! 配置ACL
ip access-list extended TIMED-ACL
permit tcp 192.168.1.0 0.0.0.255 any eq 80 time-range WORKTIME
deny tcp any any eq 8001 time-range WORKTIME
! 应用ACL到接口
interface GigabitEthernet0/1
ip access-group TIMED-ACL in
ntp server 192.168.1.100
)。
display time-range WORKTIME
(华为/华三)或show time-range
(思科/锐捷)。display acl 3000
(华为/华三)或show access-lists
(思科/锐捷)。