在重分发网络中更改管理距离定义路径

简介:
一、拓扑图:
 
 
二、配置说明与分析:
1、按照拓扑图配置各路由器的IP地址和协议,并在R2R5上做重分发,保证所有的链路的连通性。看一下R2上的重分发配置:
R2#show run
router ospf 1
 log-adjacency-changes
 redistribute rip metric 200 subnets   (RIP发进OSPF过来的cost 我定义为200)
 network 172.16.255.0 0.0.0.3 area 0
!
router rip
 redistribute ospf 1 metric 11     (ospf 发进RIP过来的cost 我定义为 11)
 network 192.168.1.0
 
2、那么应该说通过 R2这个路由后:
ospf 区域到 rip区域后 cost 将会为成为我们定义的值  11
 Rip区域到 ospf 区域后 cost 将会成为我们定义的值    200
 
3、RIP区域看一下ospf 区域过来的路由:
 
R1# sh 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 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
 
Gateway of last resort is not set
 
R    172.16.0.0/16 [120/11] via 192.168.1.2, 00:00:07, Serial1/1(ospf那边过来的,RIP把它当R)
     10.0.0.0/24 is subnetted, 1 subnets
C       10.1.1.0 is directly connected, Loopback0
C    192.168.1.0/24 is directly connected, Serial1/1
C    192.168.2.0/24 is directly connected, FastEthernet0/0
 
4、OSPF区域看一下RIP区域过来的路由:
 
R3#show 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 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
 
Gateway of last resort is not set
 
     172.16.0.0/30 is subnetted, 3 subnets
C       172.16.255.0 is directly connected, Serial1/0
C       172.16.255.4 is directly connected, Serial1/1
O       172.16.255.8 [110/128] via 172.16.255.6, 00:49:26, Serial1/1
O E2 10.0.0.0/8 [110/200] via 172.16.255.1, 00:49:26, Serial1/0
O E2 192.168.1.0/24 [110/200] via 172.16.255.1, 00:49:26, Serial1/0 (通过R2过来的定义了200)
O E1 192.168.2.0/24 [110/328] via 172.16.255.6, 00:49:26, Serial1/1(通过R5过来的,那么为什么是328呢?这条路由经过R5过来的,它会以R5上的重分发的cost值计算,因为我在R5重发布的时候做了redistribute rip metric 200 metric-type 1 subnets 这样就会叠加经过ospf 区域的costRIPàOSPF (cost 200) + R4—>R5 (cost 64) + R3—>R4 (cost 64) = cost 328)
 
5、通过上面的图示我们弄清了ripospf 区域的cost值之后,现在我们在R5上看一下路由表:
 
R5#show 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 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
 
Gateway of last resort is not set
 
     172.16.0.0/30 is subnetted, 3 subnets
O       172.16.255.0 [110/192] via 172.16.255.9, 00:03:00, Serial1/0
O       172.16.255.4 [110/128] via 172.16.255.9, 00:03:00, Serial1/0
C       172.16.255.8 is directly connected, Serial1/0
O E2 10.0.0.0/8 [110/200] via 172.16.255.9, 00:02:59, Serial1/0  (居然绕了4个路由器)
O E2 192.168.1.0/24 [110/200] via 172.16.255.9, 00:02:59, Serial1/0 (也绕远了,不直接通过R1)
C    192.168.2.0/24 is directly connected, FastEthernet0/0
R5#
 
6、我们看到 R510.0.0.0/8192.168.1.0/24都是绕了个大圈通过 ospf 区域来走,那它为什么不直接通过 R1这一跳来走呢。这样路径更近,只要通过 R1一个路由器转发就行啊。呵呵!这是因为 R5认为 R2重分发过进来路由的管理距离是 110rip120,走 ospf更短。所以不选择 R1走,而是走 R4。看来管理距离决定着路由器选择那个路由协议的路径过去。所以在这种情况之后。我们要去手动地在 R5上修改到达 R1的管理距离,强制让它选择最佳路由走 R1
 
7、我们可以通过一个 acl加指定链路的 distance来做:
R5(config)#access-list 1 permit 10.0.0.0 0.255.255.255(建立一个对目的网络的访问控制列表)
R5(config)#router rip
R5(config-router)#distance 85 192.168.2.0 0.0.0.255 1(定义到R1的管理距离为85匹配access-list1)
 
8、我们来看一下 access-list 1
R5#show access-lists 1
Standard IP access list 1
10    ermit 10.0.0.0, wildcard bits 0.255.255.255 (1 match)   已经有1个匹配了
 
9、看一下 R5 的路由表:
R5#show 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 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
 
Gateway of last resort is not set
 
     172.16.0.0/30 is subnetted, 3 subnets
O       172.16.255.0 [110/192] via 172.16.255.9, 02:32:03, Serial1/0
O       172.16.255.4 [110/128] via 172.16.255.9, 02:32:03, Serial1/0
C       172.16.255.8 is directly connected, Serial1/0
R    10.0.0.0/8 [85/1] via 192.168.2.1, 00:00:11, FastEthernet0/0 (现在变成R了,并且走R1)
E2 192.168.1.0/24 [110/200] via 172.16.255.9, 00:09:57, Serial1/0(这条路径加一条ACL就能改到走R1了,那样将会变成R不会是E2)
C    192.168.2.0/24 is directly connected, FastEthernet0/0
 
10
R2#sh 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 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
 
Gateway of last resort is not set
 
     172.16.0.0/30 is subnetted, 3 subnets
C       172.16.255.0 is directly connected, Serial1/1
O       172.16.255.4 [110/128] via 172.16.255.2, 02:46:52, Serial1/1
O       172.16.255.8 [110/192] via 172.16.255.2, 02:46:52, Serial1/1
O E1 10.0.0.0/8 [110/392] via 172.16.255.2, 00:15:01, Serial1/1
C    192.168.1.0/24 is directly connected, Serial1/0
O E1 192.168.2.0/24 [110/392] via 172.16.255.2, 02:46:52, Serial1/1
R2#
 
11、这次我来把两条都改掉管理距离让它们走 R1
 
R2(config)#access-list 1 permit 10.0.0.0 0.0.0.255 (建立第一个到目的网络的访问控制列表)
R2(config)#access-list 1 permit 192.168.2.0 0.0.0.255(建立第二个到目的网络的访问控制列表)
R2(config)#router rip
R2(config-router)#distance 85 192.168.1.1 0.0.0.0 1 (设定到R1的管理距离)
12、再来看一下R2route:
R2(config-router)#do 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 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route
 
Gateway of last resort is not set
 
     172.16.0.0/30 is subnetted, 3 subnets
C       172.16.255.0 is directly connected, Serial1/1
O       172.16.255.4 [110/128] via 172.16.255.2, 04:12:19, Serial1/1
O       172.16.255.8 [110/192] via 172.16.255.2, 04:12:19, Serial1/1
R    10.0.0.0/8 [85/1] via 192.168.1.1, 00:00:18, Serial1/0 
C    192.168.1.0/24 is directly connected, Serial1/0
R    192.168.2.0/24 [85/1] via 192.168.1.1, 00:00:18, Serial1/0
 
两条都变成 R了,都通过 R1到目的网段。不会走ospf网络。
 
 
 本文转自wxs-163 51CTO博客,原文链接:http://blog.51cto.com/supercisco/251983
 
 
相关文章
|
3月前
|
算法 安全 网络安全
数据结构之网络攻击路径(深度优先搜索)
本文介绍了如何使用深度优先搜索(DFS)算法分析网络攻击路径。在网络安全领域,DFS用于检测网络中潜在的攻击路径,帮助安全人员及时发现并阻止威胁。文中详细描述了网络图的构建、节点间的连接关系以及DFS的实现过程。通过一个具体的例子,展示了如何检测从一个普通节点到关键节点的攻击路径,并讨论了DFS算法的优缺点。提供的C++代码实现了网络图的构建和攻击路径的检测功能。
83 24
|
3月前
|
安全 网络安全 数据安全/隐私保护
访问控制列表(ACL)是网络安全中的一种重要机制,用于定义和管理对网络资源的访问权限
访问控制列表(ACL)是网络安全中的一种重要机制,用于定义和管理对网络资源的访问权限。它通过设置一系列规则,控制谁可以访问特定资源、在什么条件下访问以及可以执行哪些操作。ACL 可以应用于路由器、防火墙等设备,分为标准、扩展、基于时间和基于用户等多种类型,广泛用于企业网络和互联网中,以增强安全性和精细管理。
421 7
|
6月前
|
机器学习/深度学习 API 异构计算
7.1.3.2、使用飞桨实现基于LSTM的情感分析模型的网络定义
该文章详细介绍了如何使用飞桨框架实现基于LSTM的情感分析模型,包括网络定义、模型训练、评估和预测的完整流程,并提供了相应的代码实现。
|
3月前
|
安全 网络安全 数据安全/隐私保护
访问控制列表(ACL)是网络安全管理的重要工具,用于定义和管理网络资源的访问权限。
访问控制列表(ACL)是网络安全管理的重要工具,用于定义和管理网络资源的访问权限。ACL 可应用于路由器、防火墙等设备,通过设定规则控制访问。其类型包括标准、扩展、基于时间和基于用户的ACL,广泛用于企业网络和互联网安全中,以增强安全性、实现精细管理和灵活调整。然而,ACL 也存在管理复杂和可能影响性能的局限性。未来,ACL 将趋向智能化和自动化,与其他安全技术结合,提供更全面的安全保障。
197 4
|
3月前
|
存储 数据安全/隐私保护 云计算
多云网络环境:定义、优势与挑战
多云网络环境:定义、优势与挑战
72 5
|
3月前
|
运维 物联网 网络虚拟化
网络功能虚拟化(NFV):定义、原理及应用前景
网络功能虚拟化(NFV):定义、原理及应用前景
238 3
|
3月前
|
运维 安全 5G
|
4月前
|
自动驾驶 物联网 5G
|
5月前
|
5G 网络安全 SDN
网络功能虚拟化(NFV)和软件定义网络(SDN):赋能5G网络灵活、智能演进的关键
网络功能虚拟化(NFV)和软件定义网络(SDN):赋能5G网络灵活、智能演进的关键
136 3
|
6月前
|
安全 Java 网络安全
【认知革命】JAVA网络编程新视角:重新定义URL与URLConnection,让网络资源触手可及!
【认知革命】JAVA网络编程新视角:重新定义URL与URLConnection,让网络资源触手可及!
60 2

热门文章

最新文章