加载中...

实验ensp-ACL访问控制列表(二)


实验要求

1.PC1——>无法访问PC3和server 1

2.Client1——>无法访问Server -icmp服务(Ping不通),但是可以访问其他服务

ACL步骤:

1.创建一个访问控制规则

2.调用这个规则

拓扑图

实验步骤

1.按照拓扑搭建实验环境,为PC配置好IP地址,单区域OSPF(ospf1 area 0)实现各设备之间互通。

PC1 192.168.1.100/24 192.168.1.1(AR1—g0/0/1)
Client1 192.168.1.200/24 192.168.1.1(AR1—g0/0/1)
PC2 192.168.3.100/24 192.168.3.1(AR3—g0/0/1)
Server1 192.168.4.100/24 192.168.4.1(AR4—g0/0/1)

2.在AR2上创建ACL规则1,PC1——>无法访问PC3和server 1

[R2]acl 2000
[R2-acl-basic-2000]rule deny source 192.168.1.100 0.0.0.0
[R2-acl-basic-2000]dis th
[V200R003C00]
#
acl number 2000  
 rule 5 deny source 192.168.1.100 0 
#
return

3.尝试用PC1区访问PC3、server1.可以看见网络还是通的,原因是acl 2000还没有挂接

PC>ping 192.168.4.100

Ping 192.168.4.100: 32 data bytes, Press Ctrl_C to break
From 192.168.4.100: bytes=32 seq=1 ttl=252 time=62 ms
From 192.168.4.100: bytes=32 seq=2 ttl=252 time=47 ms
From 192.168.4.100: bytes=32 seq=3 ttl=252 time=63 ms
From 192.168.4.100: bytes=32 seq=4 ttl=252 time=31 ms
From 192.168.4.100: bytes=32 seq=5 ttl=252 time=31 ms

--- 192.168.4.100 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 31/46/63 ms

4.在AR2的入接口上挂接acl 2000

[R2-acl-basic-2000]int g0/0/0
[R2-GigabitEthernet0/0/0]traffic-filter inbound acl 2000

traffic-filter是流量过滤器的意思

5.再次尝试用PC1区访问PC3、server1.可以看见网络已经不通了

PC>ping 192.168.4.100

Ping 192.168.4.100: 32 data bytes, Press Ctrl_C to break
Request timeout!
Request timeout!
Request timeout!
Request timeout!
Request timeout!

--- 192.168.4.100 ping statistics ---
  5 packet(s) transmitted
  0 packet(s) received
  100.00% packet loss

6.这里虽然不通,但数据是已经传到AR2;使用dis acl all查看

[R2]dis acl all
 Total quantity of nonempty ACL number is 1 

Basic ACL 2000, 1 rule
Acl's step is 5
 rule 5 deny source 192.168.1.100 0 (5 matches)

可以看到有5条数据被拦截

6.在Server 1上启动Http服务,选择文件(这里以桌面上的电子书为例),点击启动按钮,打开服务

7.在Client上尝试访问Server1 ,选择客户端信息——>HttpClient——>输入server1的ip192.168.4.100——>点击获取,可以看到成功获取到server上的内容,且出现保存弹窗。

8.使用Client去Ping Server,同样可以Ping通

9.创建acl规则,Client1——>无法访问Server -icmp服务(Ping不通),但是可以访问其他服务。

思路

拒绝ICMP      拒绝 源地址 192.168.1.200————>192.168.4.100

注意:高级ACL在规则创建时需要先写协议类型,之后才是源和目的ip。比如这里需要阻止 icmp协议,就可以在deny后跟上1或者icmp。

[R2-acl-adv-3999]rule deny ?
  <1-255>  Protocol number
  gre      GRE tunneling(47)
  icmp     Internet Control Message Protocol(1)
  igmp     Internet Group Management Protocol(2)
  ip       Any IP protocol
  ipinip   IP in IP tunneling(4)
  ospf     OSPF routing protocol(89)
  tcp      Transmission Control Protocol (6)
  udp      User Datagram Protocol (17)
[R2]acl 3999
[R2-acl-adv-3999]rule deny 1 source 192.168.1.200 0 destination 192.168.4.100 0

10.将acl 3999挂接到AR2的g0/0/0的inbound口,可以看到报错了。这是因为一个设备下的一个接口的同一方向(inbound|outbound)只能挂接一个acl。一个acl下可以有多条规则

[R2-GigabitEthernet0/0/0]traffic-filter inbound acl 3999
Error: A simplified ACL has been applied in this view.

11.这里可以将之前配置的acl 2000 undo,在acl 3999上配置第二条规则来满足要求一。

也可以在Ar2的outbound接口上挂接acl 3999.其他路由器接口也可以

[R2-GigabitEthernet0/0/0]undo traffic-filter inbound 
[R2-GigabitEthernet0/0/0]traffic-filter inbound acl 3999

12.现在使用Client去Ping Server,不可以Ping通

13.在Client上尝试访问Server1 ,选择客户端信息——>HttpClient——>输入server1的ip192.168.4.100——>点击获取,可以看到依旧成功获取到server上的内容,且出现保存弹窗。

14.思考一下,现在从Server1可以Ping通Client1吗?显然是不可以的

15.那么要如何实现,在Client1无法ping通Server1的同时,Server1却可以Ping通Client1呢

这里就要我们了解ICMP-Echo/Echo reply。

[R2-acl-adv-3999]rule deny 1 source 192.168.1.200 0 destination 192.168.4.100 0 
icmp-type echo			//这条命令的意思就是阻止源ip为1.200的数据包进行echo-request请求,但是可以接收echo reply回复
						//从而实现了在Client1无法ping通Server1的同时,Server1却可以Ping通Client1
[R2-acl-adv-3999]q
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]dis th
[V200R003C00]
#
interface GigabitEthernet0/0/0
 ip address 12.1.1.2 255.255.255.0 
 traffic-filter inbound acl 3999
#
return


文章作者: okra2saber
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 okra2saber !
评论
  目录