实验拓扑图

 

 

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 1.1.1.1 255.255.255.0

R1(config-if)#exit

R1(config)#int s0/0

R1(config-if)#no shut

R1(config-if)#ip add 192.168.0.1 255.255.255.0

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 lo0

R2(config-if)#ip add 2.2.2.2 255.255.255.0

R2(config-if)#exit

R2(config)#int s0/0

R2(config-if)#no shut

R2(config-if)#ip add 192.168.0.2 255.255.255.0

R2(config-if)#exit

R2(config)#int s0/1

R2(config-if)#no shut

R2(config-if)#ip add 172.16.0.1 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 lo0

R3(config-if)#ip add 3.3.3.3 255.255.255.0

R3(config-if)#exit

R3(config)#int s0/1

R3(config-if)#no shut

R3(config-if)#ip add 172.16.0.2 255.255.255.0

R3(config-if)#exit

4.配置R1R2R3OSPF

R1(config)#router ospf 1

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

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

R1(config-router)#end

R2(config)#router ospf 1

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

R2(config-router)#net 172.16.0.1 0.0.0.0 area 1

R2(config-router)#end

R3(config)#router ospf 1

R3(config-router)#net 172.16.0.2 0.0.0.0 area 1

R3(config-router)#net 3.3.3.3 0.0.0.0 area 0

R3(config-router)#end

5.查看OSPF邻居表

R1#show ip ospf nei

 

Neighbor ID     Pri   State           Dead Time   Address         Interface

2.2.2.2           0   FULL/  -        00:00:35    192.168.0.2     Serial0/0

R2#show ip ospf nei

 

Neighbor ID     Pri   State           Dead Time   Address         Interface

1.1.1.1           0   FULL/  -        00:00:30    192.168.0.1     Serial0/0

3.3.3.3           0   FULL/  -        00:00:32    172.16.0.2      Serial0/1

R3#show ip ospf nei

 

Neighbor ID     Pri   State           Dead Time   Address         Interface

2.2.2.2           0   FULL/  -        00:00:30    172.16.0.1      Serial0/1

6.查看R1OSPF路由表

R1#show ip route ospf

     172.16.0.0/24 is subnetted, 1 subnets

O IA    172.16.0.0 [110/128] via 192.168.0.2, 00:02:28, Serial0/0

说明:R1路由表上只有一条到172.16.0.0网段的外部路由,没有Area 1的路由条目。

 

7.R2R3上配置虚链路,解决上面问题

R2(config)#router ospf 1

R2(config-router)#area 1 virtual-link 3.3.3.3  //配置虚链路

R2(config-router)#end

R3(config)#router ospf 1

R3(config-router)#area 1 virtual-link 2.2.2.2

R3(config-router)#end

8.再次查看R1的路由表

R1#show ip route ospf

     3.0.0.0/32 is subnetted, 1 subnets

O       3.3.3.3 [110/129] via 192.168.0.2, 00:01:10, Serial0/0  //路由表中出现到3.3.3.3的路由条目
  
   172.16.0.0/24 is subnetted, 1 subnets

O IA    172.16.0.0 [110/128] via 192.168.0.2, 00:01:10, Serial0/0

9.查看R1的链路状态数据库

R1#show ip ospf da

 

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

 

                Router Link States (Area 0)  //1型的LSA

 

Link ID         ADV Router      Age         Seq#       Checksum Link count

1.1.1.1         1.1.1.1         693         0x80000002 0x003674 3

2.2.2.2         2.2.2.2         153         0x80000002 0x007826 3

3.3.3.3         3.3.3.3         2     (DNA) 0x80000002 0x00A94A 2

 

                Summary Net Link States (Area 0)  //3型的LSA

 

Link ID         ADV Router      Age         Seq#       Checksum

172.16.0.0      2.2.2.2         689         0x80000001 0x004AED

172.16.0.0      3.3.3.3         522   (DNA) 0x80000001 0x002C08

10.测试连通性

R1#ping 3.3.3.3 source 1.1.1.1

 

Type escape sequence to abort.

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

Packet sent with a source address of 1.1.1.1

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 28/51/88 ms

 

实验过程