标准ACL+扩展ACL+命名ACL
拓扑图
配置全网互通
Router0
Router#conf
Router(config)#int f0/0
Router(config-if)#ip address 192.168.1.1 255.255.255.0
Router(config-if)#no shutdown
Router(config-if)#int s2/0
Router(config-if)#ip address 192.168.2.1 255.255.255.0
Router(config-if)#clock rate 128000
Router(config-if)#no shutdown
Router(config)#int f1/0
Router(config-if)#ip address 192.168.5.1 255.255.255.0
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#router rip
Router(config-router)#version 2
Router(config-router)#network 192.168.1.0
Router(config-router)#network 192.168.2.0
Router(config-router)#network 192.168.5.0
Router1
Router>enable
Router#conf
Router(config)#int s2/0
Router(config-if)#ip address 192.168.2.2 255.255.255.0
Router(config-if)#no shutdown
Router(config-if)#int s3/0
Router(config-if)#ip address 192.168.3.1 255.255.255.0
Router(config-if)#clock rate 128000
Router(config-if)#no shutdown
Router(config-if)#exit
Router(config)#router rip
Router(config-router)#version 2
Router(config-router)#network 192.168.2.0
Router(config-router)#network 192.168.3.0
Router(config-router)#exit
Router2
Router>enable
Router#conf
Router(config)#int s3/0
Router(config-if)#ip address 192.168.3.2 255.255.255.0
Router(config-if)#no shutdown
Router(config-if)#int f0/0
Router(config-if)#ip address 192.168.4.1 255.255.255.0
Router(config-if)#exit
Router(config)#router rip
Router(config-router)#version 2
Router(config-router)#network 192.168.3.0
Router(config-router)#network 192.168.4.0
Router(config-router)#
PC1
PC0
server0
1>> 标准ACL
要求 : 在router1路由器上作ACL,使网段192.168.1.0不能访问路由器2,只有pc0可以访问router2的telnet服务
在router上进行ACL设置
Router>enable
Router#conf
Router(config)#access-list 1 deny 192.168.1.0 0.0.0.255
Router(config)#access-list 1 permit any
Router(config)#int s2/0
Router(config-if)#ip access-group 1 in
Router(config-if)#exit
Router(config)#access-list 2 permit 192.168.5.2
Router(config)#line vty 0 4
Router(config-line)#access-class 2 in
Router(config-line)#password cisco
Router(config-line)#login
测试
pc1 上
PC>ping 192.168.2.2
Pinging 192.168.2.2 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Ping statistics for 192.168.2.2:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
pc0上
PC>telnet 192.168.2.2
Trying 192.168.2.2 ...Open
User Access Verification
Password:
Router>
2>> 扩展ACL
要求: 192.168.1.0 网段不能访问192.168.4.2的www服务器
192.168.5.0 网段不能ping通192.168.4.0网段。
在Router1上配置如下
Router>
Router>enable
Router#conf
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#
Router(config)#access-list 101 deny tcp 192.168.1.0 0.0.0.255 host 192.168.4.2 eq www
Router(config)#access-list 101 deny icmp 192.168.5.0 0.0.0.255 192.168.4.0 0.0.0.255
Router(config)#access-list 101 permit ip any any
Router(config)#int s2/0
Router(config-if)#ip access-group 101 in
Router(config-if)#exit
Router(config)#
测试
在pc1上测试
在PC0上测试
进行ping
PC>ping 192.168.4.2
Pinging 192.168.4.2 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.
可以看到ping 不通,但可以访问www服务器
3>> 命名ACL
命名ACL又分为标准命名ACL和扩展命名ACL
标准命名ACL
要求和标准ACL一样
要求 : 在router1路由器上作ACL,使网段192.168.1.0不能访问路由器2,只有pc0可以访问router2的telnet服务
在router上进行ACL设置
Router>
Router>enable
Router#conf
Router(config)#ip access-list standard stand
Router(config-std-nacl)#deny 192.168.1.0 0.0.0.255
Router(config-std-nacl)#permit any
Router(config-std-nacl)#int s2/0
Router(config-if)#ip access-group stand in
Router(config-if)#exit
Router(config)#ip access-list standard class
Router(config-std-nacl)#permit 192.168.5.2
Router(config-std-nacl)#line vty 0 4
Router(config-line)#access-class stand in
Router(config-line)#password cisco
Router(config-line)#login
Router(config-line)#
扩展命名ACL按照扩展ACL的要求
要求: 192.168.1.0 网段不能访问192.168.4.2的www服务器
192.168.5.0 网段不能ping通192.168.4.0网段。
在Router1上配置如下
Router>enable
Router#s
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial2/0, changed state to up
Router#show access-list
Router#conf
Router(config)#ip access-list extended extend
Router(config-ext-nacl)#deny tcp 192.168.1.0 0.0.0.255 host 192.168.4.2 eq www
Router(config-ext-nacl)#deny icmp 192.168.5.0 0.0.0.255 192.168.4.0 0.0.0.255
Router(config-ext-nacl)#permit ip any any
Router(config-ext-nacl)#int s2/0
Router(config-if)#ip access-group extend in
Router(config-if)#exit
Router(config)#