一、实验目标
利用分布列表实现对路由条目的过滤(单独允许一条或多条与单独禁止一条或多条),去掉不想要的路由条目。
二、实验意义
理解怎样在网络中对一些路由条目进行简单的过滤以及利用什么技术实现。
三、实验拓扑
实验环境:GNS3.7200路由器。
四、实验要求
1、在R1学到的路由中,只允许R3的3.3.3.3出现在路由表;
2、在R1学到的路由中,过滤R3的3.3.3.3,其他的路由仍然存在路由表。
五、实验规划
①、每台路由器都有自己的固定回环地址,R1:1.1.1.1/24(其他路由器依次类推);
②、R1,R2之间用12.12.12.0/24网段,R2,R3之间用23.23.23.0/24网段;
③、R1,R2之间用eigrp协议,R2,R3之间用ospf协议。
六、实验步骤
1、实验之前先看下R1的路由表
R1#sho iproute
Codes: C- connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O -OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 -OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPFexternal type 2
i - IS-IS, su - IS-IS summary, L1 -IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidatedefault, U - per-user static route
o - ODR, P - periodic downloaded staticroute
Gatewayof last resort is not set
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback1
2.0.0.0/24 is subnetted, 1 subnets
D 2.2.2.0 [90/2297856] via 12.12.12.2,00:03:41, Serial1/1
33.0.0.0/32 is subnetted, 1 subnets
D EX 33.33.33.33 [170/2195456] via 12.12.12.2,00:00:18, Serial1/1
3.0.0.0/32 is subnetted, 1 subnets
D EX 3.3.3.3 [170/2195456] via 12.12.12.2,00:00:18, Serial1/1
23.0.0.0/24 is subnetted, 1 subnets
D EX 23.23.23.0 [170/2195456] via 12.12.12.2,00:00:18, Serial1/1
12.0.0.0/24 is subnetted, 1 subnets
C 12.12.12.0 isdirectly connected, Serial1/1
学到了所有的路由表。
下面我们就进行路由过滤。
2、在R1学到的路由中,只允许R3的3.3.3.3出现在路由表
在R2上进行策略设置
2.1.设置访问控制列表
R2(config)#access-list 10 permit host 3.3.3.3
2.2.启用分布列表
R2(config)#router eigrp 90
R2(config-router)#distribute-list 10 out s1/0
解析:
这里设置s1/0为out方向,由于是在R1上过滤路由,没有说在R2上也过滤,所以还是允许被过滤掉的路由信息到达R2的,只是不允许其出R2到达R1罢了;如果要在R2上也过滤,则可以在进R2的接口上设置in方向即可。
2.3.查看R1路由表
R1#sho ip route
Codes: C -connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O -OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 -OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPFexternal type 2
i - IS-IS, su - IS-IS summary, L1 -IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidatedefault, U - per-user static route
o - ODR, P - periodic downloaded staticroute
Gateway of lastresort is not set
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback1
3.0.0.0/32is subnetted, 1 subnets
D EX 3.3.3.3[170/2195456] via 12.12.12.2, 00:08:57, Serial1/1
12.0.0.0/24 is subnetted, 1 subnets
C 12.12.12.0 is directly connected,Serial1/1
现在R1的路由表只存在R3的3.3.3.3/24地址。
2.4.R1 ping过滤掉的33.33.33.33地址
R1#ping33.33.33.33
Type escapesequence to abort.
Sending 5,100-byte ICMP Echos to 33.33.33.33, timeout is 2 seconds:
.....
Success rate is0 percent (0/5)
由于没有存在的路径不能ping通。
2.5.回到R3上实验能否ping通1.1.1.1
先查看R3的路由信息:
R3#sho iproute
Codes: C -connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O -OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 -OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPFexternal type 2
i - IS-IS, su - IS-IS summary, L1 -IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidatedefault, U - per-user static route
o - ODR, P - periodic downloaded staticroute
Gateway of lastresort is not set
1.0.0.0/24is subnetted, 1 subnets
O E2 1.1.1.0[110/20] via 23.23.23.1, 00:16:13, Serial1/0
2.0.0.0/24 is subnetted, 1 subnets
O E2 2.2.2.0 [110/20] via 23.23.23.1, 00:16:13,Serial1/0
33.0.0.0/24 is subnetted, 1 subnets
C 33.33.33.0 is directly connected,Loopback2
3.0.0.0/24 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Loopback1
23.0.0.0/24 is subnetted, 1 subnets
C 23.23.23.0 is directly connected,Serial1/0
12.0.0.0/24 is subnetted, 1 subnets
O E2 12.12.12.0 [110/20] via 23.23.23.1,00:16:13, Serial1/0
存在R1的路由,然后用33.33.33.33作为源地址ping1.1.1.1
R3#ping 1.1.1.1source 33.33.33.33
Type escapesequence to abort.
Sending 5,100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
Packet sent witha source address of 33.33.33.33
.....
Success rate is0 percent (0/5)
解析:
当ping1.1.1.1时,R3从路由表中调取1.1.1.1的地址,包能够到达R1,但是回来的时候,转换角色,R1成为了源路由,由于R1上没有R3的33.33.33.33地址,所以不能到达目的,也就不能回复R3了。实际上R3是ping通了R1,只是没有回复包罢了。
3. 在R1学到的路由中,过滤R3的3.3.3.3,其他的路由仍然存在路由表
3.1.依旧在R2上,先设置访问了列表
R2(config)#access-list 20 deny host 3.3.3.3
R2(config)#access-list 20 permit any
说明:
这里一定要设置permit项,否则分布列表应用之后,其他的条目将同时被过滤。
3.2.应用分布列表
R2(config)#router eigrp 90
R2(config-router)#distribute-list 20 out s1/0
3.3.查看R1路由表
R1#sho iproute
Codes: C -connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O -OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 -OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPFexternal type 2
i - IS-IS, su - IS-IS summary, L1 -IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidatedefault, U - per-user static route
o - ODR, P - periodic downloaded staticroute
Gateway of lastresort is not set
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback1
2.0.0.0/24 is subnetted, 1 subnets
D 2.2.2.0 [90/2297856] via 12.12.12.2,00:04:45, Serial1/1
33.0.0.0/32 is subnetted, 1 subnets
D EX 33.33.33.33 [170/2195456] via 12.12.12.2,00:04:45, Serial1/1
23.0.0.0/24 is subnetted, 1 subnets
D EX 23.23.23.0 [170/2195456] via 12.12.12.2,00:04:45, Serial1/1
12.0.0.0/24 is subnetted, 1 subnets
C 12.12.12.0 is directly connected,Serial1/1
3.3.3.3/24的条目被过滤了。
3.4.在R1上ping 3.3.3.3
R1#ping 3.3.3.3
Type escapesequence to abort.
Sending 5,100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
.....
Success rate is0 percent (0/5)
3.5.在R3上ping R1
R3#ping 1.1.1.1
Type escapesequence to abort.
Sending 5,100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is100 percent (5/5), round-trip min/avg/max = 80/128/220 ms
R3#ping 1.1.1.1source 3.3.3.3
Type escapesequence to abort.
Sending 5,100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
Packet sent witha source address of 3.3.3.3
.....
Success rate is0 percent (0/5)
两种ping的方式只有一个能通,这是为什么呢?
当我们过滤掉3.3.3.3后,R1上并没有这个路由条目,所以带上源3.3.3.3后再ping是不能ping通的。但是不带源3.3.3.3时,ping通是以23.23.23.0为源的,R1路由表里有这个路由条目,所以能够ping通。
结论:
以过滤后的路由为源,是不能进行通信的。
以上就是利用分布列表进行的过滤操作!!
阅读(2274) | 评论(0) | 转发(0) |