设为首页收藏本站language 语言切换
查看: 1292|回复: 1
收起左侧

[分享] 关于路由重分发,只用一篇文章就能教会你

[复制链接]
发表于 2022-1-22 14:33:21 | 显示全部楼层 |阅读模式
本帖最后由 网络工程师-老杨 于 2022-1-22 14:37 编辑


大家好,我是老杨。


今天我们照例聊聊技术,聊个没聊过的,比如说路由重分发


我们都知道啊,一个网络包含两个片区,每个片区使用各自的动态路由协议。


如果这时候,你想要实现两个片区的网络互通,就需要在两者之间打通路由。


但是,这两种动态路由协议毕竟是不同的协议,路由信息是完全隔离的,到底咋实现交互?

1.jpg


这就需要使用路由重分发(路由引入route-importation)这个玩意儿了。


为了实现多种路由协议的协同工作,路由器就可以使用路由重分发,将其学习到的一种路由协议的路由,通过另一种路由协议广播出去,这样的话,网络的所有部分都可以连通了。


为了实现重分发,路由器必须同时运行多种路由协议,这样,每种路由协议才可以取路由表中的所有或部分其他协议的路由来进行广播。


那咋配置?今天整理了全部的操作细节,都安排上了。


想学习OSPF和路由相关的系统基础,其实也很简单。厂商认证的初级课程都有涉及,逻辑完整,思路清晰,还配合实战,学过的都说好。

2.png


file:///C:\Users\SPOTO\AppData\Local\Temp\ksohtml\wps2BB6.tmp.jpg

感兴趣的小友也欢迎添加老杨微信(spotoa),咨询厂商认证的学习细节哈。

  file:///C:\Users\SPOTO\AppData\Local\Temp\ksohtml\wps2BB7.tmp.jpg
file:///C:\Users\SPOTO\AppData\Local\Temp\ksohtml\wps2BB8.tmp.jpg
路由重分发,到底怎么整?


拓扑图如下:

3.jpg

file:///C:\Users\SPOTO\AppData\Local\Temp\ksohtml\wps2BB9.tmp.jpg

说明

要实现整个网络的通信,在现实当中需要在R1上做NAT来实现与ISP的通信。


本案例省略NAT的配置,在ISP路由器上配置默认路由来实现通信,而且需要在R2和R3上配置OSPF(RIP)重分发和静态路由和直连路由的重分发,从而实现全网的互通,具体的配置如下:


(1)配置各路由器,以及OSPF协议、RIP协议、静态路由、接口IP地址


R1的配置如下:

接口地址

R1#conf t

R1(config)#int lo0

R1(config-if)#ip add 1.1.1.1 255.255.255.255

R1(config-if)#no sh

R1(config-if)#exit

R1(config)#int e0/0

R1(config-if)#ip add 10.0.0.5 255.255.255.252

R1(config-if)#no sh

R1(config-if)#exit

R1(config)#int e0/1

R1(config-if)#ip add 172.16.31.1 255.255.255.252

R1(config-if)#no sh

R1(config-if)#exit

R1(config)#int e0/2

R1(config-if)#ip add 192.168.1.1 255.255.255.0

R1(config-if)#no sh

R1(config-if)#exit

R1(config)#int e0/3

R1(config-if)#ip add 10.0.0.1 255.255.255.252

R1(config-if)#no sh

R1(config-if)#exit


OSPF协议

R1(config)#router ospf 1

R1(config-router)#router-id 1.1.1.1

R1(config-router)#network 1.1.1.1 0.0.0.0 area 0

R1(config-router)#network 10.0.0.0 0.0.0.3 area 0

R1(config-router)#network 10.0.0.4 0.0.0.3 area 1

R1(config-router)#network 192.168.1.0 0.0.0.255 area 0

R1(config-router)#exit


默认路由

R1(config)#ip route 0.0.0.0 0.0.0.0 172.16.31.2



R2的配置如下:

接口地址

R2#conf t

R2(config)#int lo0

R2(config-if)#ip add 2.2.2.2 255.255.255.255

R2(config-if)#no sh

R2(config-if)#exit

R2(config)#int e0/0

R2(config-if)#ip add 10.0.0.2 255.255.255.252

R2(config-if)#no sh

R2(config-if)#exit

R2(config)#int e0/1

R2(config-if)#ip add 192.168.100.1 255.255.255.0

R2(config-if)#no sh

R2(config-if)#exit


OSPF协议

R2(config)#router ospf 1

R2(config-router)#router-id 2.2.2.2

R2(config-router)#network 2.2.2.2 0.0.0.0 area 0

R2(config-router)#network 10.0.0.0 0.0.0.3 area 0

R2(config-router)#exit


RIP协议

R2(config)#router rip         

R2(config-router)#version 2           

R2(config-router)#network 192.168.100.0

R2(config-router)#exit



R3的配置如下:

接口地址

R3#conf t

R3(config)#int lo0

R3(config-if)#ip add 3.3.3.3 255.255.255.255

R3(config-if)#no sh

R3(config-if)#exit

R3(config)#int e0/0

R3(config-if)#ip add 10.0.0.6 255.255.255.252

R3(config-if)#no sh

R3(config-if)#exit

R3(config)#int e0/1

R3(config-if)#ip add 10.0.0.9 255.255.255.252

R3(config-if)#no sh

R3(config-if)#exit

OSPF协议

R3(config)#router ospf 1

R3(config-router)#router-id 3.3.3.3

R3(config-router)#network 3.3.3.3 0.0.0.0 area 1

R3(config-router)#network 10.0.0.4 0.0.0.3 area 1

R3(config-router)#exit


静态路由

R3(config)#ip route 192.168.3.0 255.255.255.0 10.0.0.10



R4的配置如下:

接口地址

R4#conf t

R4(config)#int lo0

R4(config-if)#ip add 4.4.4.4 255.255.255.255

R4(config-if)#no sh

R4(config-if)#exit

R4(config)#int e0/0

R4(config-if)#ip add 192.168.3.1 255.255.255.0

R4(config-if)#no sh

R4(config-if)#exit

R4(config)#int e0/1

R4(config-if)#ip add 10.0.0.10 255.255.255.252

R4(config-if)#no sh

R4(config-if)#exit


默认路由

R4(config)#ip route 0.0.0.0 0.0.0.0 10.0.0.9



R5的配置如下:

接口地址

R5#conf t

R5(config)#int e0/0

R5(config-if)#ip add 192.168.2.1 255.255.255.0

R5(config-if)#no sh

R5(config-if)#int e0/1

R5(config-if)#ip add 192.168.100.2 255.255.255.0

R5(config-if)#no sh

R5(config-if)#exit


RIP协议

R5(config)#router rip

R5(config-router)#version 2

R5(config-router)#network 192.168.100.0

R5(config-router)#network 192.168.2.0

R5(config-router)#exit



ISP的配置如下:

接口地址

ISP#conf t

ISP(config)#int e0/0

ISP(config-if)#ip add 59.56.61.1 255.255.255.0

ISP(config-if)#no sh

ISP(config-if)#exit

ISP(config)#int e0/1

ISP(config-if)#ip add 172.16.31.2 255.255.255.252

ISP(config-if)#no sh

ISP(config-if)#exit


默认路由

ISP(config)#ip route 0.0.0.0 0.0.0.0 172.16.31.1



(2)配置路由重分发


在R1上重分发默认路由,配置如下:

R1(config)#router ospf 1

R1(config-router)#default-information originate

R1(config-router)#exit



在R2重分发OSPF和RIP,配置如下:

R2(config)#router ospf 1

R2(config-router)#redistribute rip subnets

R2(config-router)#exit

R2(config)#router rip

R2(config-router)#redistribute ospf 1 metric 3

R2(config-router)#exit



在R3上重分发静态路由和直连路由,配置如下:

R3(config)#router ospf 1

R3(config-router)#redistribute static subnets

R3(config-router)#redistribute connected subnets

R3(config-router)#exit



(3)验证网络通信是否正常

查看R1、R2、R3、R5的路由表,并使用ping命令验证网络是否正常通信。


R1的路由表:

R1#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 172.16.31.2 to network 0.0.0.0

     1.0.0.0/32 is subnetted, 1 subnets

C       1.1.1.1 is directly connected, Loopback0

     2.0.0.0/32 is subnetted, 1 subnets

O       2.2.2.2 [110/11] via 10.0.0.2, 02:41:47, Ethernet0/3

     3.0.0.0/32 is subnetted, 1 subnets

O       3.3.3.3 [110/11] via 10.0.0.6, 02:39:45, Ethernet0/0

     172.16.0.0/30 is subnetted, 1 subnets

C       172.16.31.0 is directly connected, Ethernet0/1

     10.0.0.0/30 is subnetted, 3 subnets

O E2    10.0.0.8 [110/20] via 10.0.0.6, 02:39:39, Ethernet0/0

C       10.0.0.0 is directly connected, Ethernet0/3

C       10.0.0.4 is directly connected, Ethernet0/0

C    192.168.1.0/24 is directly connected, Ethernet0/2

O E2 192.168.2.0/24 [110/20] via 10.0.0.2, 02:40:07, Ethernet0/3

O E2 192.168.100.0/24 [110/20] via 10.0.0.2, 02:40:07, Ethernet0/3

O E2 192.168.3.0/24 [110/20] via 10.0.0.6, 02:40:07, Ethernet0/0

S*   0.0.0.0/0 [1/0] via 172.16.31.2(默认路由重分发)



R2的路由表:

R2#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 10.0.0.1 to network 0.0.0.0


     1.0.0.0/32 is subnetted, 1 subnets

O       1.1.1.1 [110/11] via 10.0.0.1, 02:42:10, Ethernet0/0

     2.0.0.0/32 is subnetted, 1 subnets

C       2.2.2.2 is directly connected, Loopback0

     3.0.0.0/32 is subnetted, 1 subnets

O IA    3.3.3.3 [110/21] via 10.0.0.1, 02:42:10, Ethernet0/0

     10.0.0.0/30 is subnetted, 3 subnets

O E2    10.0.0.8 [110/20] via 10.0.0.1, 02:40:00, Ethernet0/0

C       10.0.0.0 is directly connected, Ethernet0/0

O IA    10.0.0.4 [110/20] via 10.0.0.1, 02:42:12, Ethernet0/0

O    192.168.1.0/24 [110/20] via 10.0.0.1, 02:42:12, Ethernet0/0

R    192.168.2.0/24 [120/1] via 192.168.100.2, 00:00:14, Ethernet0/1

C    192.168.100.0/24 is directly connected, Ethernet0/1

O E2 192.168.3.0/24 [110/20] via 10.0.0.1, 02:40:06, Ethernet0/0

O*E2 0.0.0.0/0 [110/1] via 10.0.0.1, 02:40:06, Ethernet0/0(RIP的重分发)


R3的路由表:

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 10.0.0.5 to network 0.0.0.0

     1.0.0.0/32 is subnetted, 1 subnets

O IA    1.1.1.1 [110/11] via 10.0.0.5, 02:41:33, Ethernet0/0

     2.0.0.0/32 is subnetted, 1 subnets

O IA    2.2.2.2 [110/21] via 10.0.0.5, 02:41:33, Ethernet0/0

     3.0.0.0/32 is subnetted, 1 subnets

C       3.3.3.3 is directly connected, Loopback0

     10.0.0.0/30 is subnetted, 3 subnets

C       10.0.0.8 is directly connected, Ethernet0/1

O IA    10.0.0.0 [110/20] via 10.0.0.5, 02:41:33, Ethernet0/0

C       10.0.0.4 is directly connected, Ethernet0/0

O IA 192.168.1.0/24 [110/20] via 10.0.0.5, 02:41:35, Ethernet0/0

O E2 192.168.2.0/24 [110/20] via 10.0.0.5, 02:41:35, Ethernet0/0

O E2 192.168.100.0/24 [110/20] via 10.0.0.5, 02:41:35, Ethernet0/0

S    192.168.3.0/24 [1/0] via 10.0.0.10

O*E2 0.0.0.0/0 [110/1] via 10.0.0.5, 02:41:36, Ethernet0/0(静态路由和直连路由的重分发)


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 192.168.100.1 to network 0.0.0.0

R    1.0.0.0/8 [120/3] via 192.168.100.1, 00:00:17, Ethernet0/1

R    2.0.0.0/8 [120/3] via 192.168.100.1, 00:00:17, Ethernet0/1

R    3.0.0.0/8 [120/3] via 192.168.100.1, 00:00:17, Ethernet0/1

R    10.0.0.0/8 [120/3] via 192.168.100.1, 00:00:17, Ethernet0/1

R    192.168.1.0/24 [120/3] via 192.168.100.1, 00:00:17, Ethernet0/1

C    192.168.2.0/24 is directly connected, Ethernet0/0

C    192.168.100.0/24 is directly connected, Ethernet0/1

R    192.168.3.0/24 [120/3] via 192.168.100.1, 00:00:19, Ethernet0/1

R*   0.0.0.0/0 [120/3] via 192.168.100.1, 00:00:19, Ethernet0/1(OSPF的重分发)


在R4上pingISP和R5

R4#ping 59.56.61.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 59.56.61.1, timeout is 2 seconds:

!!!!!(能够正常通信)

Success rate is 100 percent (5/5), round-trip min/avg/max = 84/99/120 ms

R4#ping 192.168.2.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds:

!!!!!(能够正常通信)

Success rate is 100 percent (5/5), round-trip min/avg/max = 124/132/152 ms


文章来源:内容综合自网络,由本号梳理成文。因觉优质,特此分享,侵删。


老杨,一个从事网工行业8年的中年吃货,和你每天聊几句关于网工的那些事儿。
微信图片_20211203090946.png

您需要登录后才可以回帖 登录 | 论坛注册

本版积分规则

QQ|Archiver|手机版|小黑屋|sitemap|鸿鹄论坛 ( 京ICP备14027439号 )  

GMT+8, 2025-2-3 10:06 , Processed in 0.055983 second(s), 15 queries , Redis On.  

  Powered by Discuz!

  © 2001-2025 HH010.COM

快速回复 返回顶部 返回列表