OSPF中路由重分发的实例

网络拓扑

说明:要实现整个网络的通信,在现实当中需要在R1上做NAT来实现与ISP的通信,本案例省略NAT的配置,在ISP路由器上配置默认路由来实现通信,而且需要在R2R3上配置OSPFRIP)重分发和静态路由和直连路由的重分发,从而实现全网的互通,具体的配置如下:

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重分发OSPFRIP,配置如下:

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)验证网络通信是否正常

查看R1R2R3R5的路由表,并使用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的重分发)

 

R4pingISPR5

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

猜你喜欢

转载自blog.csdn.net/weixin_42342456/article/details/82980201
今日推荐