1. ACL概述
(1)、ACL全称访问控制列表(Access Control List)。
(2)、基本原理:ACL使用包过滤技术,在路由器上读取第三层及第四层包头中的信息(如源地址、目的地址、协议口、端口号等),根据预先定义好的规则对包进行过滤,从而达到控制的目的。
(3)ACL目的:限制网络流量、提高网络性能;提供对通信流量的控制手段;提供网络访问的基本安全手段。
(4)、功能:网络中的结点分为资源结点和用户结点两大类,其中资源结点提供服务或数据,而用户结点访问资源结点所提供的服务与数据。ACL的主要功能就是一方面保护资源结点,阻止非法用户对资源结点的访问;另一方面限制特定的用户结点对资源结点的访问权限。
(5)、ACL的访问顺序
a、按照各语句在访问列表的顺序,顺序查找,一旦找到了某一匹配条件,就结束匹配,不再检查后面的语句。
b、如果所有语句都没有匹配,在默认情况下,虽然看不到最后一行,但最后总是拒绝全部流量的。
ACL的作用
1.用来对数据包做访问控制(丢弃或者放行)
2.结合其他协议,用来匹配范围
ACL种类
- 1.基本acl (2000-2999) :只能匹配源ip地址。
- 2.高级acl (3000-3999) :可以匹配源ip、目标ip、源端口、目标端口等三层和四层的字段层
ACL工作原理
当数据包从接口经过时,由于接口启用了ACL,此时路由器会对报文进行检查,然后做出相应的处理。
ACL是一组规则的集合,它应用在路由器的某个接口上。对路由器接口而言,ACL有两个方向。
出:已经过路由器的处理,正离开路由器接口的数据包
入:已经过路由器接口的数据包,将被路由器处理
实验拓扑及实验要求:
PC及服务器设置:
SW1
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en
Info: Information center is disabled.
[Huawei]sys sw1
[sw1]vlan batch 10 20 30
Info: This operation may take a few seconds. Please wait for a moment...done.
[sw1]int e0/0/1
[sw1-Ethernet0/0/1]p l a
[sw1-Ethernet0/0/1]p d v 10
[sw1-Ethernet0/0/1]int e0/0/2
[sw1-Ethernet0/0/2]p l a
[sw1-Ethernet0/0/2]p d v 20
[sw1-Ethernet0/0/2]int e0/0/3
[sw1-Ethernet0/0/3]p l a
[sw1-Ethernet0/0/3]p d v 30
[sw1-Ethernet0/0/3]int vlan 10
[sw1-Vlanif10]ip add 192.168.1.254 24
[sw1-Vlanif10]int vlan 20
[sw1-Vlanif20]ip add 192.168.2.254 24
[sw1-Vlanif20]int vlan 30
[sw1-Vlanif30]ip add 172.16.1.1 30
[sw1-Vlanif30]q
[sw1]ip route-static 0.0.0.0 0 172.16.1.2
[sw1]q
SW2
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]un in en
Info: Information center is disabled.
[Huawei]sys sw2
[sw2]v b 10 20 30 40 50
Info: This operation may take a few seconds. Please wait for a moment...done.
[sw2]int e0/0/1
[sw2-Ethernet0/0/1]p l a
[sw2-Ethernet0/0/1]p d v 40
[sw2-Ethernet0/0/1]int e0/0/2
[sw2-Ethernet0/0/2]p l a
[sw2-Ethernet0/0/2]p d v 50
[sw2-Ethernet0/0/2]q
[sw2]int vlan 50
[sw2-Vlanif50]ip add 172.16.2.1 30
[sw2-Vlanif50]int vlan 40
[sw2-Vlanif40]ip add 172.16.1.2 30
[sw2-Vlanif40]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]
[sw2]ip route-static 0.0.0.0 0 172.16.2.2
AR1
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]
[Huawei]un in en
Info: Information center is disabled.
[Huawei]
[Huawei]sys R1
[R1]
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]
[R1-GigabitEthernet0/0/0]ip add 172.16.2.2 30
[R1-GigabitEthernet0/0/0]
[R1-GigabitEthernet0/0/0]int g0/0/1
[R1-GigabitEthernet0/0/1]
[R1-GigabitEthernet0/0/1]ip add 192.168.3.254 24
[R1-GigabitEthernet0/0/1]
[R1-GigabitEthernet0/0/1]int g0/0/2
[R1-GigabitEthernet0/0/2]
[R1-GigabitEthernet0/0/2]ip add 192.168.4.254 24
[R1-GigabitEthernet0/0/2]
[R1-GigabitEthernet0/0/2]q
[R1]
[R1]ip route-static 192.168.1.0 24 172.16.2.1
[R1]
[R1]ip route-static 192.168.2.0 24 172.16.2.1
[R1]
设置规则AR1
[R1]acl 3000
[R1-acl-adv-3000]
[R1-acl-adv-3000]rule 5 permit tcp source 192.168.1.0 0.0.0.255 destination 192.
168.4.1 0 destination-port eq 80
[R1-acl-adv-3000]
[R1-acl-adv-3000]rule 10 deny tcp source 192.168.1.0 0.0.0.255 destination 192.1
68.3.1 0 destination-port eq 21
[R1-acl-adv-3000]
[R1-acl-adv-3000]rule 15 permit tcp source 192.168.2.0 0.0.0.255 destination 192
.168.3.1 0 destination-port eq 21
[R1-acl-adv-3000]
[R1-acl-adv-3000]rule 20 deny tcp source 192.168.2.0 0.0.0.255 destination 192.1
68.4.1 0 destination-port eq 80
[R1-acl-adv-3000]
[R1-acl-adv-3000]q
[R1]
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]
[R1-GigabitEthernet0/0/0]traffic-filter inbound acl 3000
实验结果:
财务部可以访问WEB服务器
在WEB服务器上上传一个文件
使用client3访问
不可以访问FTP服务器
开启ftp服务
显示访问不到
市场部允许访问FTP服务器
不允许访问WEB服务器