扩展访问控制列表 CISCO之CCNA篇之七(3)

在访问控制列表(ACL)简介 CISCO之CCNA篇之七(1)这篇文章中我们已经提到了标准的访问列表,下面就用两个实例来详细介绍下具体的应用。
扩展访问控制列表语法:
Lab(config)#access-list [100-199] [permit/deny] 协议 源IP 源IP反码 目标IP 目标IP反码 条件[eq] [具体协议/端口号]
举个语法实例,便于大家理解:
Lab(config)#access-list 101 deny tcp 192.168.1.10 0.0.0.0 172.16.1.2 0.0.0.0 eq telnet
或Lab(config)#access-list 101 deny tcp host 192.168.1.10 host 172.16.1.2 eq 23
注意:只禁用某个服务(或某个端口)需要把其他设置打开
Lab(config)#access-list 101 permit ip any any
Lab(config)#int fa0/0  (绑定到接口上)
Lab(config-if)#ip class-group 101 in
注:eq 等于;gt 大于;lt 小于;neq 不等于。
扩展ACL实验一:只禁用PC0对外网服务器(Server0)的http访问
具体是实验拓扑图如下图
30
Server0充当外网服务器,它需要的配置如下 ,为其开启DNS服务,添加域名www.itet.com
31
然后再为其开启HTTP服务,随便输入一些粗糙的网页内容,见下图标注处,
32
路由器R1需要的配置(基本的IP配置见上图)
r1>
r1>en
r1#sh run
Building configuration...
Current configuration : 460 bytes
!
version 12.2
no service password-encryption
!
hostname r1

ip ssh version 1
!
interface FastEthernet0/0
ip address 192.168.1.1 255.255.255.0
  ip access-group 101 in
duplex auto
speed auto
!
interface FastEthernet0/1
ip address 202.106.1.1 255.255.255.0
duplex auto
speed auto
!
ip classless
!
access-list 101 deny tcp host 192.168.1.2 host 202.106.1.2 eq www
access-list 101 permit ip any any
!
line con 0
line vty 0 4
login
!
end

实验结果,先来看下面的图,打开“WEB浏览器”,
33
先在PC0上进行域名访问,连接不上,
34
然后再在PC1上进行域名访问,成功进入我们自己设置的网页界面,
35
通过这个测试,我们成功的禁用了PC0对外网服务器(Server0)的HTTP访问 ,下面我们再举一例,介绍扩展ACL的应用。
扩展ACL实验二:只禁用PC1对R2的PING操作
具体的实验拓扑图如下:
36
路由器R1的配置如下:
r1>
r1>en
r1# sh run
Building configuration...
Current configuration : 639 bytes
!
version 12.2
no service password-encryption
!
hostname r1
!
ip ssh version 1
!
interface FastEthernet0/0
ip address 192.168.1.1 255.255.255.0
ip access-group 101 in
duplex auto
speed auto
!
interface FastEthernet0/1
no ip address
duplex auto
speed auto
shutdown
!
interface Serial0/0
ip address 172.16.1.1 255.255.255.0
clock rate 64000
!
interface Serial0/1
no ip address
shutdown
!
ip classless
!
!
access-list 101 deny icmp host 192.168.1.2 host 172.16.1.2 echo
access-list 101 deny icmp host 192.168.1.2 host 172.16.1.2 echo-reply
access-list 101 permit ip any any
!
line con 0
line vty 0 4
login
!
end
路由器R2的配置如下:
r2>
r2>en
r2# sh run
Building configuration...
Current configuration : 463 bytes
!
version 12.2
no service password-encryption
!
hostname r2
!
ip ssh version 1
!
interface FastEthernet0/0
no ip address
duplex auto
speed auto
shutdown
!
interface FastEthernet0/1
no ip address
duplex auto
speed auto
shutdown
!
interface Serial0/0
ip address 172.16.1.2 255.255.255.0
!
interface Serial0/1
no ip address
shutdown
!
ip classless
ip route 192.168.1.0 255.255.255.0 172.16.1.1
!
line con 0
line vty 0 4
login
!
end

实验结果:还是先来看下面的图,PC1在PING路由器R2时已经不能通信了,
37
看PC2和路由器R2可以正常通信,不受影响,
38
同理,PC3也可以喝路由器R2正常通信,
39
有上面的三个图片,可以很容易看出,只有PC1不能PING通R2,说明我们的实验成功,建的扩展ACL生效。
ACL还有更多的应用,由于篇幅问题,这里就先介绍这么多,欢迎阅读后续文章。

本文出自 “冰泉” 博客,谢绝转载!

你可能感兴趣的:(列表,访问,Cisco,休闲,CCNA)