>汽车>>正文

【高新课堂】第六十期--OSPF的路由重分发配置

原标题:【高新课堂】第六十期--OSPF的路由重分发配置

OSPF的路由重分发配置

为什么需要使用路由重分发及路由重分发的作用

在大型的企业中,可能在同一网内使用到多种路由协议,为了实现多种路由协议的协同工作,路由器可以使用路由重分发(route redistribution)将其学习到的一种路由协议的路由通过另一种路由协议广播出去,这样网络的所有部分都可以连通了。为了实现重分发,路由器必须同时运行多种路由协议,这样,每种路由协议才可以取路由表中的所有或部分其他协议的路由来进行广播

开始配置吧

拓扑图如下:

说明:要实现整个网络的通信,在现实当中需要在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

来源:思科CCIE俱乐部

END返回搜狐,查看更多

责任编辑:

声明:该文观点仅代表作者本人,搜狐号系信息发布平台,搜狐仅提供信息存储空间服务。
isp rip config metric ping命令
阅读 ()
投诉
免费获取
今日搜狐热点
今日推荐