标准访问控制列表
access-list 1 deny|permit 原地址 通配符(0.0.0.255)
access-list 1 permit any(匹配所有ip 0.0.0.0 255.255.255.255 = any 禁止访问某ip:192.168.1.1 0.0.0.0 = host 192.168.1.1)
ip access-group 1 out|in
扩展访问控制列表
access-list 100 deny 协议 源地址 通配符 目地地址 通配符
access-list 100 deny ip 192.168.1.0 0.0.0.31 host 192.168.2.200(禁止192.168.1.1-31 访问2.200)
access-list 100 permit ip any any
ip access-group 100 out|in
命名访问控制列表
ip access-list standard|extended(类型为标准或扩展)列表名
序号 deny|permit 协议 源地址 通配符 目地地址 通配符
ip access-list standard test
10 deny tcp 192.168.12.0 0.0.0.255 any eq 23
20 permit ip any any 注释:最前面的10、20是序号
ip access-group test out|in
1、每个接口,每个方向,每种协议,只能设置一个acl
2、ACL只能禁止流量通过某设备,不能禁止流量从自身设备流出
3、匹配度最高的列表中的行放在最前面
4、不可能从acl列表中除去一行,除去一行意味着除去整个列表,命名访问例外
5、默认acl结尾语句是deny any,所以语句结尾要加permit any
6、创建完acl后要应用在需要过滤的接口上,注意in和out
7、尽可能把ip标准acl放置在离目标近的地方,把ip扩展acl放置在离源地址近的地方
例:三台路由器可以互通,R1开启了远程登录,现通过在R2上配置ACL来禁止R3 telnet到R1
R1(config)#int s0/0
R1(config-if)#ip add 192.168.12.1 255.255.255.0
R1(config-if)#no shut
R1(config)#ip route 0.0.0.0 0.0.0.0 192.168.12.2
R1#ping 192.168.23.3
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.23.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 72/102/164 ms
R1(config)#line vty 0 4
R1(config-line)#pass
R1(config-line)#password 123
R1(config-line)#login
R3(config)#int s0/0
R3(config-if)#ip add 192.168.23.3 255.255.255.0
R3(config-if)#no shut
R3(config)#ip route 0.0.0.0 0.0.0.0 192.168.23.2
R3#telnet 192.168.12.1 (没ACL之前)
Trying 192.168.12.1 ... Open
User Access Verification
Password:
R1>exit
[Connection to 192.168.12.1 closed by foreign host]
R3#telnet 192.168.12.1 (使用ACL之后)
Trying 192.168.12.1 ...
% Destination unreachable; gateway or host down
R2(config)#int s0/0
R2(config-if)#ip add 192.168.12.2 255.255.255.0
R2(config-if)#no shut
R2(config-if)#int s0/1
R2(config-if)#ip add 192.168.23.2 255.255.255.0
R2(config-if)#no shut
R2(config)#ip access-list extended name1
R2(config-ext-nacl)#10 deny tcp 192.168.23.0 0.0.0.255 any eq 23
R2(config-ext-nacl)#20 permit ip any any
R2(config-ext-nacl)#end
R2(config)#int s0/0
R2(config-if)#ip access-group name1 out
R2(config-if)#end
R2#show access-list
Extended IP access list name1
10 deny tcp 192.168.23.0 0.0.0.255 any eq telnet (2 matches)
20 permit ip any any
ACL访问控制列表
最新推荐文章于 2023-05-06 23:08:48 发布