码迷,mamicode.com
首页 > 其他好文 > 详细

标准ACL配置实例

时间:2019-10-14 10:30:48      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:ip地址   list   size   地址   pre   config   配置   实例   log   

访问控制列表(一)

结构:

技术图片

一.访问控制列表概述:

访问控制列表(ACL)

1.读取第三层、第四层包头信息

2.根据预先定义好的规则对包进行过滤

技术图片

二.访问控制类表的工作原理

访问控制列表在接口应用的方向:

出:已经过路由器的处理,正离开路由器接口的数据包

入:已达到路由器接口的数据包,将被路由器处理

列表应用到接口方向与数据方向有关

访问控制列表的处理过程:

技术图片

ACL规则:匹配为自上而下逐条匹配,默认隐含的拒绝是拒绝所有(any)

白名单:

允许 1.2
允许 1.3
拒绝所有(不写)

黑名单:

拒绝 1.2
拒绝 1.3
允许所有(必须写)

三.ACL访问控制列表的类型:

标准访问控制列表:

1.基于IP地址过滤数据包
2.标准访问控制列表的访问控制列表号是1~99

扩展访问控制列表:

1.基于源IP、目标IP地址、指定协议、端口和标志来过滤数据包
2.扩展访问控制列表的访问控制列表号是100~199

命名访问控制列表(包含标准和扩展):

1.命名访问控制列表允许在标准和扩展访问控制列表中使用名称待敌表号

可灵活调整策略

四.标准访问控制列表的配置

创建ACL:

Router(config)#access-list accsee-list-number
    { permit允许数据包通过 | deny拒绝数据包通过 } source [ source-wildcard ]可对源IP进行控制

删除ACL:

Router(config)#no access-list access-list-number

应用实例:

Router(config)# access-list 1 permit 192.168.1.0 0.0.0.255
Router(config)# access-list 1 permit 192.168.2.2 0.0.0.0
允许192.168.1.0/24和主机192.168.2.2的流量通过

隐含的拒绝语句:

Router(config)# access-list 1 deny 0.0.0.0 255.255.255.255

关键字:

host/any

Demo1:标准ACL的配置实例

技术图片

交换机:
sw#conf t 
sw(config)#no ip routing
sw(config)#int f1/0
sw(config-if)#speed 100
sw(config-if)#dup full
路由器:
R1#conf t
R1(config)#int f0/0
R1(config-if)#ip add 192.168.10.1 255.255.255.0
R1(config-if)#no shut
R1(config-if)#int f0/1
R1(config-if)#ip add 192.168.20.1 255.255.255.0
R1(config-if)#no shut
客户机配置IP地址:
PC1> ip 192.168.10.2 192.168.10.1
Checking for duplicate address...
PC1 : 192.168.10.2 255.255.255.0 gateway 192.168.10.1

PC2> ip 192.168.10.3 192.168.10.1 
Checking for duplicate address...
PC1 : 192.168.10.3 255.255.255.0 gateway 192.168.10.1

PC3> 
PC3> ip 192.168.20.2 192.168.20.1
Checking for duplicate address...
PC1 : 192.168.20.2 255.255.255.0 gateway 192.168.20.1
验证互通:
PC1> ping 192.168.20.2           
192.168.20.2 icmp_seq=1 timeout
84 bytes from 192.168.20.2 icmp_seq=2 ttl=63 time=15.676 ms
84 bytes from 192.168.20.2 icmp_seq=3 ttl=63 time=17.680 ms
84 bytes from 192.168.20.2 icmp_seq=4 ttl=63 time=21.956 ms
84 bytes from 192.168.20.2 icmp_seq=5 ttl=63 time=12.700 ms

PC2> ping 192.168.20.2
192.168.20.2 icmp_seq=1 timeout
192.168.20.2 icmp_seq=2 timeout
84 bytes from 192.168.20.2 icmp_seq=3 ttl=63 time=17.735 ms
84 bytes from 192.168.20.2 icmp_seq=4 ttl=63 time=14.069 ms
84 bytes from 192.168.20.2 icmp_seq=5 ttl=63 time=14.960 ms

//此时全网段互通
全局模式下在R1上定义规则
R1(config-if)#access-list 1 deny host 192.168.10.2
R1(config)#do show access-list
R1(config)#access-list 1 permit any
R1(config)#int f0/0
R1(config-if)#ip access-group 1 in
PC1pingPC3显示管理员拒绝:
PC1> ping 192.168.20.2
*192.168.10.1 icmp_seq=1 ttl=255 time=20.233 ms (ICMP type:3, code:13, Communication administratively prohibited)
*192.168.10.1 icmp_seq=2 ttl=255 time=4.913 ms (ICMP type:3, code:13, Communication administratively prohibited)
*192.168.10.1 icmp_seq=3 ttl=255 time=12.927 ms (ICMP type:3, code:13, Communication administratively prohibited)
*192.168.10.1 icmp_seq=4 ttl=255 time=12.965 ms (ICMP type:3, code:13, Communication administratively prohibited)
*192.168.10.1 icmp_seq=5 ttl=255 time=13.958 ms (ICMP type:3, code:13, Communication administratively prohibited)
PC1pingPC2可以连通:
PC1>ping 192.168.10.3
84 bytes from 192.168.10.3 icmp_seq=1 ttl=64 time=0.000 ms
84 bytes from 192.168.10.3 icmp_seq=2 ttl=64 time=0.975 ms
84 bytes from 192.168.10.3 icmp_seq=3 ttl=64 time=0.997 ms
84 bytes from 192.168.10.3 icmp_seq=4 ttl=64 time=0.000 ms
84 bytes from 192.168.10.3 icmp_seq=5 ttl=64 time=1.731 ms

标准ACL配置实例

标签:ip地址   list   size   地址   pre   config   配置   实例   log   

原文地址:https://blog.51cto.com/14464303/2442057

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!