实验拓扑图

 

实验过程

1.R1的预配置

Router>en

Router#config t

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#no ip domain-lookup

Router(config)#line console 0

Router(config-line)#no exec-timeout

Router(config-line)#loggin syn

Router(config-line)#exit

Router(config)#host R1

R1(config)#int lo0

R1(config-if)#ip add 172.16.1.1 255.255.255.0

R1(config-if)#exit

R1(config)#int lo1

R1(config-if)#ip add 172.16.2.1 255.255.255.0

R1(config-if)#exit

R1(config)#int s0/0

R1(config-if)#no shut

R1(config-if)#ip add 172.16.255.1 255.255.255.252

R1(config-if)#exit

2.R2的预配置

Router>en

Router#config t

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#no ip domain-lookup

Router(config)#line console 0

Router(config-line)#no exec-timeout

Router(config-line)#loggin syn

Router(config-line)#exit

Router(config)#host R2

R2(config)#int s0/0

R2(config-if)#no shut

R2(config-if)#ip add 172.16.255.2 255.255.255.252

R2(config-if)#exit

R2(config)#int s0/1

R2(config-if)#no shut

R2(config-if)#ip add 192.168.255.2 255.255.255.0

R2(config-if)#exit

3.R3的预配置

Router>en

Router#config t

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#no ip domain-lookup

Router(config)#line console 0

Router(config-line)#no exec-timeout

Router(config-line)#loggin syn

Router(config-line)#exit

Router(config)#host R3

R3(config)#int s0/1

R3(config-if)#no shut

R3(config-if)#ip add 192.168.255.1 255.255.255.0

R3(config-if)#exit

R3(config)#int lo0

R3(config-if)#ip add 192.168.1.1 255.255.255.0

R3(config-if)#exit

R3(config)#int lo1

R3(config-if)#ip add 192.168.2.1 255.255.255.0

R3(config-if)#exit

4.R1ospf配置

R1(config)#router ospf 1

R1(config-router)#net 172.16.1.1 0.0.0.0 area 0

R1(config-router)#net 172.16.2.1 0.0.0.0 area 0

R1(config-router)#net 172.16.255.1 0.0.0.0 area 0

R1(config-router)#end

5.R2ospfrip配置

R2(config)#router ospf 1

R2(config-router)#net 172.16.255.2 0.0.0.0 area 0

R2(config-router)#exit

R2(config)#router rip

R2(config-router)#version 2

R2(config-router)#no auto

R2(config-router)#net 192.168.255.0

R2(config-router)#end

6.R3rip配置

R3(config)#router rip

R3(config-router)#version 2

R3(config-router)#no auto

R3(config-router)#net 192.168.255.0

R3(config-router)#net 192.168.1.0

R3(config-router)#net 192.168.2.0

R3(config-router)#end

7.查看R1R3的路由表

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 not set

 

     172.16.0.0/16 is variably subnetted, 3 subnets, 2 masks

C       172.16.255.0/30 is directly connected, Serial0/0

C       172.16.1.0/24 is directly connected, Loopback0

C       172.16.2.0/24 is directly connected, Loopback1

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

 

C    192.168.255.0/24 is directly connected, Serial0/1

C    192.168.1.0/24 is directly connected, Loopback0

C    192.168.2.0/24 is directly connected, Loopback1

说明:R1R3只有自己直连的网段信息,没有整个网络的信息,为了解决此问题,需要在R2上配置重发布。

8.R2上配置重发布

R2(config)#router ospf 1

R2(config-router)#redistribute rip metric 100 subnet  //rip重发布进ospf中,metric改为100,并且携带子网

R2(config-router)#exit

R2(config)#router rip

R2(config-router)#redistribute ospf 1 metric 10  //ospf重发布进rip中,metric改为10

R2(config-router)#exit

9.查看R1R3的路由表

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 not set

 

     172.16.0.0/16 is variably subnetted, 3 subnets, 2 masks

C       172.16.255.0/30 is directly connected, Serial0/0

C       172.16.1.0/24 is directly connected, Loopback0

C       172.16.2.0/24 is directly connected, Loopback1

O E2 192.168.255.0/24 [110/100] via 172.16.255.2, 00:02:52, Serial0/0

O E2 192.168.1.0/24 [110/100] via 172.16.255.2, 00:02:52, Serial0/0

O E2 192.168.2.0/24 [110/100] via 172.16.255.2, 00:02:52, Serial0/0

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/16 is variably subnetted, 3 subnets, 2 masks

R       172.16.255.0/30 [120/10] via 192.168.255.2, 00:00:10, Serial0/1

R       172.16.1.1/32 [120/10] via 192.168.255.2, 00:00:10, Serial0/1

R       172.16.2.1/32 [120/10] via 192.168.255.2, 00:00:10, Serial0/1

C    192.168.255.0/24 is directly connected, Serial0/1

C    192.168.1.0/24 is directly connected, Loopback0

C    192.168.2.0/24 is directly connected, Loopback1

说明:R1学习到了rip重发布进来的路由,默认是O E2R3学习到了ospf重发布进来的路由。

 

10.R1上查看ospf链路状态数据库

R1#show ip ospf da

 

            OSPF Router with ID (172.16.2.1) (Process ID 1)

 

                Router Link States (Area 0)

 

Link ID         ADV Router      Age         Seq#       Checksum Link count

172.16.2.1      172.16.2.1      1031        0x80000002 0x00AEF1 4

192.168.255.2   192.168.255.2   426         0x80000002 0x00CDC4 2

 

                Type-5 AS External Link States  //重发布进来的路由是5型的

 

Link ID         ADV Router      Age         Seq#       Checksum Tag

192.168.1.0     192.168.255.2   426         0x80000001 0x003644 0

192.168.2.0     192.168.255.2   426         0x80000001 0x002B4E 0

192.168.255.0   192.168.255.2   426         0x80000001 0x00413A 0

11.测试连通性

R1#ping 192.168.1.1 source lo0

 

Type escape sequence to abort.

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

Packet sent with a source address of 172.16.1.1

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 12/44/80 ms

R1#ping 192.168.2.1 source lo0

 

Type escape sequence to abort.

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

Packet sent with a source address of 172.16.1.1

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 36/59/72 ms