ACL分爲基本ACL和高級ACL。
基本ACL只能基於數據包的源地址、報文分片標記和時間段來定義規則。
高級ACL可以根據數據包的源IP地址、目標IP地址、目標端口、源端口、數據包的長度值來定義規則
基本ACL
需求:
- 不允許vlan 30 訪問 Internet區域
- vlan10 週一至週五9點至17點能訪問Internet
- vlan 10在週六、週日不允許訪問Internet
- vlan 20允許訪問Internet區域
拓撲圖
先調通網絡的連通性:
R1# ip route-static 0.0.0.0 0.0.0.0 10.1.1.2
R2# ip route-static 0.0.0.0 0.0.0.0 10.1.1.1
配置基本ACL
基本ACL的編號範圍爲2000-2999
定義時間段
[R1]time-range vlan10-1 9:00 to 17:00 working-day
//vlan10-1是時間段的命名,由自己定義;這條命令表示週一至週五的9點-17點
[R1]time-range vlan10-2 00:00 to 23:59 off-day
//這條命令表示週六周天,全天的時間
創建基本ACL
acl number 2000 //自定義編號(範圍爲2000-2999)
rule 10 deny source 13.1.1.10 0
rule 20 permit source 11.1.1.10 0 time-range vlan10-1
rule 30 permit source 11.1.1.10 0 time-range vlan10-2
rule 40 permit source 12.1.1.10 0
rule 50 deny
應用在R1的outbound方向上
interface GigabitEthernet0/0/0
ip address 10.1.1.1 255.255.255.0
traffic-filter outbound acl 2000
驗證ACL
修改路由時間和日期,測試時間規則是否生效
用戶模式下:
* clock datetime 18:00:00 2019-7-25 (週五18點0分0秒)
高級ACL
高級ACL的編號範圍爲3000-3999,
需求
- 允許VLAN20訪問Internet的80端口
拓撲圖
創建高級ACL
acl number 3001
rule 10 permit ip source 12.1.1.10 0 destination 13.1.1.10 0
rule 25 permit tcp source 12.1.1.11 0 destination 21.1.1.10 0 destination-port eq www
rule 50 deny ip
應用在vlan 20 的 inbound 方向上
interface Vlanif20
ip address 12.1.1.1 255.255.255.0
traffic-filter inbound acl 3001