实验目的
        练习扩展访问列表的配置。
实验拓扑
ACL
实验过程
1.配置路由器的基本参数
R1(config)#interface s1/2
R1(config-if)#ip address 192.168.0.1 255.255.255.0
R1(config-if)#no shutdown
R2(config)#interface serial2/1
R2(config-if)#clock rate 64000
R2(config-if)#ip address 192.168.0.2 255.255.255.0
R2(config-if)#no shutdown
2.测试连通性
R2#ping 192.168.0.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.0.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 28/53/96 ms
//说明相互连通
3.创建ACL
R1(config)#access-list 100 deny icmp 192.168.0.1 0.0.0.0 192.168.0.2 0.0.0.0
//扩展访问列表ACL的编号范围100到199; 我们要拒绝的是ping命令,它是属于ICMP协议,所以我们需要拒绝ICMP ; 用反掩码绝对匹配一个源地址;用反掩码拒绝匹配一个目的地址
R1(config)#access-list 100 permit ip any any
//ACL有隐含拒绝的条目,它会拒绝所有的数据流量,为了防止数据流被误拒绝,我们加一条放行所有数据流的条目
4。检查ACL
R1#show ip access-lists
Extended IP access list 100
    deny icmp host 192.168.0.1 host 192.168.0.2
    permit ip any any
5.应用ACL到接口
R1(config)#interface serial1/2
R1(config-if)#ip access-group 100 out
//对出去的数据流量进行检测
验证效果
R1#ping 192.168.0.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.0.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 32/53/92 ms
//实验失败!现在依然可以PING通
为什么???
问题分析:对于ACL的放置位置,我们有以下的原则;扩展ACL放置在靠近源的位置,标准ACL放置在靠近目的位置。那按照上述的原则,我们创建一个扩展的ACL,并放置在源端,并没有错误。
7.排错
R1#show ip access-lists
Extended IP access list 100
    deny icmp host 192.168.0.1 host 192.168.0.2
    permit ip any any
问题分析:对于ACL,有一个非常重要的特性,他不能过滤本地数据流!也就是说,对于R1上发送的数据,设置在R1接口上的ACL并不能对它进行过滤。为了能对数据流及逆行那个过滤,我们需要把ACL设置在对端的R2上。
8.在R2上设置应用ACL
R2(config)#access-list 100 deny icmp host 192.168.0.1 host 192.168.0.2
R2(config)#access-list 100 deny icmp host 192.168.0.1 host 192.168.0.2
R2(config)#access-list 100 deny icmp any any
R2(config)#interface serial2/1
R2(config-if)#ip access-group 100 in
//对于R2来说,数据是进到S2/1接口中,所以我们需要对进来的数据进行检测,那么我们就用in
9.检测效果
R1#ping 192.168.1.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)