笔记--(5)、acl ACL
1.ppt
2.实验1
1.配置acl规则
[Huawei]acl 2000
# 精准匹配
[Huawei-acl-basic-2000]rule deny source 192.168.1.1 0.0.0.0
[Huawei-acl-basic-2000]dis this
#
acl number 2000
rule 5 deny source 192.168.1.1 0
#
此时:pc互相都可以ping通
2.应用acl规则
给 g0/0/1 应用了 inbound 流量过滤
# 给 g0/0/1 应用了 inbound 流量过滤
[Huawei]int g0/0/1
[Huawei-GigabitEthernet0/0/1]traffic-filter inbound acl 2000
[Huawei-GigabitEthernet0/0/1]dis this
#
interface GigabitEthernet0/0/1
traffic-filter inbound acl 2000
#
此时:会发现pc1无法ping通其他pc,pc2和pc3可以通
这样并不能解决问题,取消刚才的应用:
[Huawei-GigabitEthernet0/0/1]undo traffic-filter inbound acl 2000
给 g0/0/2 应用 outbound 流量过滤
# 给 g0/0/2 应用 outbound 流量过滤
[Huawei]int g 0/0/2
[Huawei-GigabitEthernet0/0/2]traffic-filter outbound acl 2000
[Huawei-GigabitEthernet0/0/2]dis this
#
interface GigabitEthernet0/0/2
traffic-filter outbound acl 2000
此时:pc1 ping pc2 不通,pc1 ping pc3 通,pc2 ping pc3 通,pc2 ping pc1 不通(有去无回)
3.实验2
1.交换机配置网关
# 交换机上配置网关的ip
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]dis this
[V200R003C00]
#
interface GigabitEthernet0/0/0
ip address 192.168.1.254 255.255.255.0
#
return
[Huawei-GigabitEthernet0/0/0]int g0/0/1
[Huawei-GigabitEthernet0/0/1]dis this
[V200R003C00]
#
interface GigabitEthernet0/0/1
ip address 192.168.3.254 255.255.255.0
#
return
[Huawei-GigabitEthernet0/0/1]int g0/0/2
[Huawei-GigabitEthernet0/0/2]dis this
[V200R003C00]
#
interface GigabitEthernet0/0/2
ip address 192.168.2.254 255.255.255.0
#
return
此时:pc互相都可以ping通
2.配置acl规则
2.1.基本acl
[Huawei]acl 2000
[Huawei-acl-basic-2000]rule deny source 192.168.2.0 0.0.0.255
[Huawei-acl-basic-2000]dis this
[V200R003C00]
#
acl number 2000
rule 5 deny source 192.168.2.0 0.0.0.255
#
2.2.高级acl
[Huawei]acl 3000
# 除了ip协议,还可以配置tcp、udp、ospf、icmp等协议,可用 ? 查看,如:rule deny ?
[Huawei-acl-adv-3000]rule deny ip source 192.168.2.0 0.0.0.255 destination 192.168.3.0 0.0.0.255
[Huawei-acl-adv-3000]dis this
[V200R003C00]
#
acl number 3000
rule 5 deny ip source 192.168.2.0 0.0.0.255 destination 192.168.3.0 0.0.0.255
#
此时:acl规则并未生效,所以pc互相都可以ping通
3.应用acl规则
在路由器的g0/0/1进行流量过滤
[Huawei]int g0/0/1
# inbound、outbound
[Huawei-GigabitEthernet0/0/1]traffic-filter outbound acl 2000
[Huawei-GigabitEthernet0/0/1]dis this
[V200R003C00]
#
interface GigabitEthernet0/0/1
ip address 192.168.3.254 255.255.255.0
traffic-filter outbound acl 2000
#
此时:pc1无法ping通pc3,市场部无法访问机房了
4.其他
H3C的配置:禁止一些常见病毒的端口通信
ddress 192.168.3.254 255.255.255.0
traffic-filter outbound acl 2000
此时:pc1无法ping通pc3,市场部无法访问机房了
# 4.其他
H3C的配置:禁止一些常见病毒的端口通信
![在这里插入图片描述](https://i-blog.csdnimg.cn/direct/91fcdf175cc14a9b94daa4a8f549b247.png#pic_center)