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

简介:
一、拓扑图:
 
 
二、配置说明与分析:
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月前
|
安全 Java Unix
网络IO管理
网络IO管理
35 0
|
1月前
|
网络协议 Shell Linux
【Shell 命令集合 网络通讯 】Linux 追踪数据包在网络中的路径 traceroute命令 使用指南
【Shell 命令集合 网络通讯 】Linux 追踪数据包在网络中的路径 traceroute命令 使用指南
40 0
|
4天前
|
安全 数据建模 网络安全
深入理解SSL数字证书:定义、工作原理与网络安全的重要性
本文阐述了SSL数字证书在网络安全中的关键作用,定义了其作为验证服务器身份的数字凭证,基于PKI体系保障数据传输安全。文章介绍了三种类型的证书,包括DV、OV和EV,适用于不同安全需求的网站。获取和安装证书涉及向证书颁发机构申请并部署到服务器。在网络安全挑战下,正确使用和管理SSL证书对于保护用户数据和提升信任度至关重要。
|
5月前
|
存储 监控 Cloud Native
剖析Linux网络包接收过程:掌握数据如何被捕获和分发的全过程(上)
剖析Linux网络包接收过程:掌握数据如何被捕获和分发的全过程
|
2月前
|
网络协议 物联网 Linux
WireGuard 系列文章(五):Netmaker 简介 - 创建和管理 WireGuard 网络的平台
WireGuard 系列文章(五):Netmaker 简介 - 创建和管理 WireGuard 网络的平台
|
3月前
|
监控 NoSQL Linux
网络IO管理 - 多路复用IO
网络IO管理 - 多路复用IO
|
3月前
|
缓存 Java 程序员
网络IO管理-简单一问一答、多线程方式
网络IO管理-简单一问一答、多线程方式
|
9月前
|
定位技术
GIS空间分析 网络分析2规划最佳路径
在本文中,你将学习到ArcGIS中 网络分析2规划最佳路径的详细过程
65 0
|
5月前
|
存储 网络协议 Linux
剖析Linux网络包接收过程:掌握数据如何被捕获和分发的全过程(下)
剖析Linux网络包接收过程:掌握数据如何被捕获和分发的全过程
|
6月前
|
Kubernetes 容器 Perl
【K8S系列】第四讲:kubadm部署k8s时service-cidr网络和pod-network-cidr的地址如何定义
【K8S系列】第四讲:kubadm部署k8s时service-cidr网络和pod-network-cidr的地址如何定义
226 0