配置路由重分发

拓扑图

clip_p_w_picpath002

实际需求

Ø 为了便于网络维护,总公司到各分公司之间使用OSPF协议,上海分公司内部使用RIP协议,而杭州分公司内部使用静态路由。

Ø 所有分公司访问公网都需要通过总公司R1路由器实现(R1路由器配置为默认路由,ISP路由器也配置为默认路由)。

Ø 各路由器互联地址如拓扑图所示,路由器的Loopback0地址为

R1:1.1.1.1/32 ,R2:2.2.2.2/32,R3:3.3.3.3/32 ,R4:4.4.4.4/32

实现步骤

1.配置各路由器接口地址,配置路由(OSPF协议、RIP协议、静态路由、默认路由)。

①配置R1

1)配置接口IP地址

R1(config)#interface e0/0

R1(config-if)#ip address 10.0.0.1 255.255.255.252

R1(config-if)#no shutdown

R1(config-if)#exit

R1(config)#interface e0/1

R1(config-if)#ip address 10.0.0.5 255.255.255.252

R1(config-if)#no shutdown

R1(config-if)#exit

R1(config)#interface e0/2

R1(config-if)#ip address 201.204.6.1 255.255.255.0

R1(config-if)#no shutdown

R1(config-if)#exit

R1(config)#interface e0/3

R1(config-if)#ip address 192.168.1.1 255.255.255.0

R1(config-if)#no shutdown

R1(config-if)#exit

R1(config)#interface loopback 0

R1(config-if)#ip address 1.1.1.1 255.255.255.255

R1(config-if)#no shutdown

R1(config-if)#exit

2)配置路由

R1(config)#router ospf 1

R1(config-router)#router-id 1.1.1.1

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

R1(config-router)#network 10.0.0.5 0.0.0.0 area 1

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

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

R1(config)#ip route 0.0.0.0 0.0.0.0 201.204.6.2

②配置R2

1)配置接口IP地址

R2(config)#interface e0/0

R2(config-if)#ip address 10.0.0.2 255.255.255.252

R2(config-if)#no shutdown

R2(config-if)#exit

R2(config)#interface e0/1

R2(config-if)#ip address 192.168.100.1 255.255.255.0

R2(config-if)#no shutdown

R2(config-if)#exit

R2(config)#interface loopback 0

R2(config-if)#ip address 2.2.2.2 255.255.255.255

R2(config-if)#no shutdown

R2(config-if)#exit

2)配置路由

R2(config)#router ospf 1

R2(config-router)#router-id 2.2.2.2

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

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

R2(config)#router rip

R2(config-router)#version 2

R2(config-router)#no auto-summary

R2(config-router)#network 192.168.100.0

③配置R3

1)配置接口IP地址

R3(config)#interface e0/0

R3(config-if)#ip address 10.0.0.9 255.255.255.252

R3(config-if)#no shutdown

R3(config-if)#exit

R3(config)#interface e0/1

R3(config-if)#ip address 10.0.0.6 255.255.255.252

R3(config-if)#no shutdown

R3(config-if)#exit

R3(config-if)#ip address 3.3.3.3 255.255.255.255

R3(config-if)#no shutdown

R3(config-if)#exit

2) 配置路由

R3(config)#router ospf 1

R3(config-router)#router-id 3.3.3.3

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

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

R3(config)#ip route 192.168.3.0 255.255.255.0 10.0.0.10

④配置R4

1)配置接口IP地址

R4(config)#interface e0/0

R4(config-if)#ip address 10.0.0.10 255.255.255.252

R4(config-if)#no shutdown

R4(config-if)#exit

R4(config)#interface e0/1

R4(config-if)#ip address 192.168.3.1 255.255.255.0

R4(config-if)#no shutdown

R4(config-if)#exit

R4(config)#interface loopback 0

R4(config-if)#ip address 4.4.4.4 255.255.255.255

R4(config-if)#no shutdown

R4(config-if)#exit

2)配置路由

R4(config)#ip route 0.0.0.0 0.0.0.0 10.0.0.9

⑤配置R5

1)配置接口IP地址

R5(config)#interface e0/0

R5(config-if)#ip address 192.168.100.2 255.255.255.0

R5(config-if)#no shutdown

R5(config-if)#exit

R5(config)#interface e0/1

R5(config-if)#ip address 192.168.2.1 255.255.255.0

R5(config-if)#no shutdown

R5(config-if)#exit

2)配置路由

R5(config)#router rip

R5(config-router)#version 2

R5(config-router)#no auto-summary

R5(config-router)#network 192.168.100.0

R5(config-router)#network 192.168.2.0

⑥配置ISP路由器

1) 配置接口地址

ISP(config)#interface e0/0

ISP(config-if)#ip address201.204.6.2 255.255.255.0

ISP(config-if)#no shutdown

ISP(config-if)#exit

ISP(config)#interface e0/1

ISP(config-if)#ip address200.1.1.1 255.255.255.0

ISP(config-if)#no shutdown

ISP(config-if)#exit

2)配置路由

ISP(config)#ip route 0.0.0.0 0.0.0.0 201.204.6.1

2.查看各路由器路由表

R1

clip_p_w_picpath004

R2

clip_p_w_picpath006

R3

clip_p_w_picpath008

R4

clip_p_w_picpath010

R5

clip_p_w_picpath012

R6

clip_p_w_picpath014

从上面各路由器的路由表中可以看出,只能在各自的自治系统内学习路由,因此要实现全网互通,需要配置路由重分发,让多个自治系统之间能够学习路由。

3..配置路由重分发(只能在ASBR上配置重分发)

①R1路由器重分发默认路由

R1(config)#router ospf 1

R1(config-router)#default-information originate

②R2路由器重分发RIP和OSPF

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

4.验证全网是否能够互通

①查看各路由器路由表,看是否学习到所有路由

R1

clip_p_w_picpath016

R2

clip_p_w_picpath018

R3

clip_p_w_picpath020

R4

clip_p_w_picpath022

R5

clip_p_w_picpath024

R6

clip_p_w_picpath026

②测试全网互通

1)在路由器R4上测试

clip_p_w_picpath028

2) 在路由器R5上测试

clip_p_w_picpath030

3)在路由器ISP上测试

clip_p_w_picpath032