且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

标准ACL

更新时间:2022-09-20 23:35:26

标准ACL

流量控制工具
ACL : access control list , 访问 控制 列表 。
-作用
基于一定的规则,进行数据流量的匹配。
仅仅是用于流量的匹配。
对这些规则的后续处理动作,是由调用ACL的工具来决定的。
-分类
标准ACL:在匹配流量时,只能匹配流量的源IP地址;
扩展ACL:在匹配流量时,可以同时匹配流量的源IP地址、
目标IP地址、TCP/UDP+端口号
标准ACL离源ip最近扩展ACL离目标最近
-表示
ID:通过数字来表示不同的ACL;
name:通过名字来表示不同的ACL;
-原理
一个ACL,就是一套规则。
一个ACL中,就有多个不同的细分条目;
不同的条目之间,是通过编号进行区分的;
通过ACL匹配流量时,是按照编号从小到大的顺序,依次检查
每个“细分条目”的:
如果能匹配住,则执行前面的动作(deny/permit);
如果不能,则继续检查下一个“细分条目”
如果到最后都没有匹配住,则执行 ACL 最后一个
默认的“细分条目” --- 拒绝所有(deny any )!
注意:
任何一种类型的ACL,最后都有一个“拒绝所有”的条目

-配置步骤:
#定义ACL
R4:
ip acces-list standard deny-ping 
10 deny 192.168.12.0 0.0.0.255
20 permit any 
#调用ACL
R4:
interface fas0/1 
ip access-group deny-ping in 
#验证ACL
R4; 
show ip access-list 
#流量测试
在所有设备上: ping 10.10.4.4 , 
R1无法通 , 其他都通。

注意: 
    标准ACL匹配流量时,不够精确,所以我们强烈建议:
      将标准ACL调用在距离“目标”特别近的地方。

标准ACL

R1:
en
R1#configure terminal 
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int fas0/0
R1(config-if)#no shu
R1(config-if)#ip add 192.168.1.1 255.255.255.0
R1(config-if)#exi
R1(config)#int loopback 10
R1(config-if)#no shu
R1(config-if)#ip add 10.10.1.1 255.255.255.0
R1(config-if)#ex
R1(config)#ip routing
R1(config)#ip route 192.168.2.0 255.255.255.0 192.168.1.2
R1(config)#ip route 192.168.3.0 255.255.255.0 192.168.2.2
R1(config)#ip route 10.10.4.0 255.255.255.0 192.168.3.2 
R1(config)#exit
R1#show ip route
R1#ping 10.10.4.4(ping不通)

R2:
en 
R2#configure terminal 
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#int f0/1
R2(config-if)#no shu
R2(config-if)#ip add 192.168.1.2 255.255.255.0 
R2(config-if)#exit
R2(config)#int fas0/0
R2(config-if)#no shu
R2(config-if)#ip add 192.168.2.1 255.255.255.0
R2(config-if)#exit
R2(config)#ip routing
R2(config)#ip route 192.168.3.0 255.255.255.0 192.168.2.2
R2(config)#ip route 10.10.1.0 255.255.255.0 192.168.1.1 
R2(config)#ip route 10.10.4.0 255.255.255.0 192.168.3.2
R2(config)#exit
R2#show ip route
R2#ping 10.10.4.4(ping通)

R3:

en
R3#configure t
Enter configuration commands, one per line. End with CNTL/Z.
R3(config)#int fas0/1
R3(config-if)#no shu
R3(config-if)#ip add 192.168.2.2 255.255.255.0 
R3(config-if)#exit
R3(config)#int fas0/0
R3(config-if)#no shu
R3(config-if)#ip add 192.168.3.1 255.255.255.0
R3(config-if)#exit
R3(config)#ip routing
R3(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1
R3(config)#ip route 10.10.1.0 255.255.255.0 192.168.1.1 
R3(config)#ip route 10.10.4.0 255.255.255.0 192.168.3.2
R3(config)#exit
R3#show ip route
R2#ping 10.10.4.4(ping通)

R4:
R4>en
R4#conf
R4#configure t 
R4#configure terminal 
Enter configuration commands, one per line. End with CNTL/Z.
R4(config)#int fas0/1
R4(config-if)#no shu
R4(config-if)#ip add 192.168.3.2 255.255.255.0 
R4(config-if)#exit
R4(config)#interface loopback 20
R4(config-if)#no shu
R4(config-if)#ip add 10.10.4.4 255.255.255.0 
R4(config-if)#exit
R4(config)#ip routing
R4(config)#ip route 192.168.2.0 255.255.255.0 192.168.3.1
R4(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1
R4(config)#ip route 10.10.1.0 255.255.255.0 192.168.1.1 
R4(config)#exit
R4#show ip route
R4(config)#ip access-list standard ab
R4(config-std-nacl)#10 deny 192.168.1.0 0.0.0.255 (拒绝192.168.1.0 网段)
R4(config-std-nacl)#20 permit any (允许所有)
R4(config-std-nacl)#exit
R4(config)#interface fas0/1
R4(config-if)#ip access-group ab in (fas0/1进入ACL)
R4(config-if)#exit
R4#show ip access-lists



本文转自 linuxpp 51CTO博客,原文链接:http://blog.51cto.com/13505118/2049329,如需转载请自行联系原作者