R0上做如下设置
R0(config)#int s0/0
R0(config-if)#no shutdown
R0(config-if)#ip add 172.16.1.1 255.255.255.0
R0(config-if)#int lo 0
R0(config-if)#no shutdown
R0(config-if)#ip add 1.1.1.1 255.255.255.0
R0(config-if)#router ospf 1 ospf进程号,本地有意义
R0(config-router)#network 1.1.1.0 0.0.0.255 area 0 network 网络号 反向掩码 area 区域号(一个区域的必须一致,否则无法形成邻接关系)
R0(config-router)#network 172.16.1.0 0.0.0.255 area 0
R0#sh ip ospf neighbor 查看ospf邻居表
Neighbor ID Pri State Dead Time Address Interface
2.2.2.2 1 FULL/ - 00:00:31 full表示已经达成邻接关系
Neighbor is up for 00:38:51 172.16.1.2 Serial0/0
R0#sh ip ospf database 查看ospf数据库
OSPF Router with ID (1.1.1.1) (Process ID 1)
Router Link States (Area 0)
Link ID ADV Router Age Seq# Checksum Link count
1.1.1.1 1.1.1.1 511 0x80000004 0xE718 3
2.2.2.2 2.2.2.2 390 0x80000006 0xD0A2 5
3.3.3.3 3.3.3.3 300 0x80000004 0xC0CD 3
R1上做如下设置
R1(config)#int s0/0
R1(config-if)#no shutdown
R1(config-if)#ip add 172.16.1.2 255.255.255.0
R1(config-if)#int s0/1
R1(config-if)#no shutdown
R1(config-if)#ip add 192.168.1.2 255.255.255.0
R1(config-if)#int lo 0
R1(config-if)#no shutdown
R1(config-if)#ip add 2.2.2.2 255.255.255.0
R1(config-if)#router ospf 2
R1(config-router)#network 2.2.2.0 0.0.0.255 area 0
R1(config-router)#network 192.168.1.0 0.0.0.255 area 0
R1(config-router)#network 172.16.1.0 0.0.0.255 area 0
R2上做如下设置
R2(config)#int s0/0
R2(config-if)#no shutdown
R2(config-if)#ip add 192.168.1.1 255.255.255.0
R2(config-if)#int lo 0
R2(config-if)#no shutdown
R2(config-if)#ip add 3.3.3.3 255.255.255.0
R2(config-if)#router ospf 3
R2(config-router)#network 3.3.3.0 0.0.0.255 area 0
R2(config-router)#network 192.168.1.0 0.0.0.255 area 0