访问控制列表ACL(Access Control List)是由一条或多条规则组成的集合。所谓规则,是指描述报文匹配条件的判断语句,这些条件可以是报文的源地址、目的地址、端口号等。
ACL本质上是一种过滤器,规则是过滤器的滤芯。设备基于这些规则进行报文匹配,可以过滤出特定的报文,并根据应用ACL的业务模块的处理策略来允许或阻止该报文通过。
以下列实验为例
实验需求:
1.接入层划分vlan,三层交换作为网关
2.允许财务部访问web服务器,不允许访问ftp服务器
3.允许市场部访问ftp服务器,不允许访问web服务器
拓扑图
先配置财务部和市场部的ip和网关
财务部
市场部
为了方便实验操作,建议在每台设备配置如下命令。关闭日志消息,会话超时设为120分钟。
system
undo info enable
user-int con 0
idle-timeout 120
quit
1.接入层划分vlan,三层交换作为网关
sys SW1
vlan batch 10 20 30
int e0/0/1
[SW1-Ethernet0/0/1]port link-type access
[SW1-Ethernet0/0/1]port default vlan 10
[SW1-Ethernet0/0/1]int e0/0/2
[SW1-Ethernet0/0/2]port link-type access
[SW1-Ethernet0/0/2]port default vlan 20
[SW1-Ethernet0/0/2]int e0/0/3
[SW1-Ethernet0/0/3]port link-type access
[SW1-Ethernet0/0/3]port default vlan 30
[SW1-Ethernet0/0/3]q
[SW1]int Vlanif 10
[SW1-Vlanif10]ip address 192.168.1.254 24
[SW1-Vlanif10]int Vlanif 20
[SW1-Vlanif20]ip address 192.168.2.254 24
[SW1-Vlanif20]int Vlanif 30
[SW1-Vlanif30]ip address 172.16.1.1 30
[SW1-Vlanif30]q
[SW1]ip route-s
[SW1]ip route-static 0.0.0.0 0 172.16.1.2
sys SW2
[SW2]vlan b
[SW2]vlan batch 40 50
[SW2]int e0/0/1
[SW2-Ethernet0/0/1]port link-type trunk
[SW2-Ethernet0/0/1]port link-type ac
[SW2-Ethernet0/0/1]port link-type access
[SW2-Ethernet0/0/1]port de
[SW2-Ethernet0/0/1]port default vlan 40
[SW2-Ethernet0/0/1]int e0/0/2
[SW2-Ethernet0/0/2]port link-type access
[SW2-Ethernet0/0/2]port default vlan 50
[SW2-Ethernet0/0/2]q
[SW2]int Vlanif 40
[SW2-Vlanif40]ip address 172.16.1.2 30
[SW2-Vlanif40]int Vlanif 50
[SW2-Vlanif50]ip address 172.16.2.1 30
[SW2-Vlanif50]q
[SW2]ip route-static 192.168.1.0 24 172.16.1.1
[SW2]ip route-static 192.168.2.0 24 172.16.1.1
[SW2]ip route-static 0.0.0.0 0 172.16.2.2
[SW2]q
sysname R1(基础配置略)
2.允许财务部访问web服务器,不允许访问ftp服务器
R1
acl number 3000
rule 5 permit tcp source 192.168.1.0 0.0.0.255 destination 192.168.4.1 0 destination-port eq www
rule 10 deny tcp source 192.168.1.0 0.0.0.255 destination 192.168.3.1 0 destination-port eq ftp
ip route-static 192.168.1.0 255.255.255.0 172.16.2.1
ping web服务器,ftp服务器均可以ping通
访问web服务器成功
访问ftp服务器失败
3.允许市场部访问ftp服务器,不允许访问web服务器
R1
acl number 3000
rule 15 permit tcp source 192.168.2.0 0.0.0.255 destination 192.168.3.1 0 destination-port eq ftp
rule 20 deny tcp source 192.168.2.0 0.0.0.255 destination 192.168.4.1 0 destination-port eq www
ip route-static 192.168.2.0 255.255.255.0 172.16.2.1
ping web服务器,ftp服务器均可以ping通
访问ftp服务器成功
访问web服务器失败