R1配置
r1(config)#int s2/1
r1(config-if)#ip ad 12.0.0.1 255.255.255.0
r1(config-if)#no sh
r1(config-if)#int lo0
r1(config-if)#ip ad 1.1.1.1 255.255.255.0
r1(config-if)#no sh
R2配置
r2(config)#int s2/1
r2(config-if)#ip ad 12.0.0.2 255.255.255.0
r2(config-if)#no sh
r2(config-if)#int s2/2
r2(config-if)#ip ad 23.0.0.2 255.255.255.0
r2(config-if)#no sh
r2(config-if)#int lo0
r2(config-if)#ip ad 2.2.2.2 255.255.255.0
R3配置
r3(config)#int s2/1
r3(config-if)#ip ad 23.0.0.3 255.255.255.0
r3(config-if)#no sh
r3(config-if)#int s2/2
r3(config-if)#ip ad 34.0.0.3 255.255.255.0
r3(config-if)#no sh
r3(config-if)#int lo0
r3(config-if)#ip ad 3.3.3.3 255.255.255.0
R4配置
r4(config)#int s2/1
r4(config-if)#ip ad 34.0.0.4 255.255.255.0
r4(config-if)#no sh
r4(config-if)#int lo0
r4(config-if)#ip ad 4.4.4.4 255.255.255.0
R1路由配置
r1(config)#router os 100
r1(config-router)#net 12.0.0.1 0.0.0.0 a 1
r1(config-router)#net 1.1.1.1 0.0.0.0 a 1
r1(config-router)#end
R2路由配置
r2(config)#router os 100
r2(config-router)#net 12.0.0.2 0.0.0.0 a 1
r2(config-router)#net 23.0.0.2 0.0.0.0 a 0
r2(config-router)#net 2.2.2.2 0.0.0.0 a 0
r2(config-router)#end
R3路由配置
r3(config)#router os 100
r3(config-router)#net 23.0.0.3 0.0.0.0 a 0
r3(config-router)#net 3.3.3.3 0.0.0.0 a 0
r3(config-router)#net 34.0.0.3 0.0.0.0 a 2
r3(config-router)#end
R4路由配置
r4(config)#router os 100
r4(config-router)#net 34.0.0.4 0.0.0.0 a 2
r4(config-router)#net 4.4.4.4 0.0.0.0 a 2
r4(config-router)#end
查看路由器上的OSPF邻居信息
r1#sh ip os nei
Neighbor ID Pri State Dead Time Address Interface
2.2.2.2 0 FULL/ - 00:00:31 12.0.0.2 Serial2/1
r2#sh ip os nei
Neighbor ID Pri State Dead Time Address Interface
3.3.3.3 0 FULL/ - 00:00:31 23.0.0.3 Serial2/2
1.1.1.1 0 FULL/ - 00:00:36 12.0.0.1 Serial2/1
r3#sh ip os nei
Neighbor ID Pri State Dead Time Address Interface
2.2.2.2 0 FULL/ - 00:00:32 23.0.0.2 Serial2/1
4.4.4.4 0 FULL/ - 00:00:34 34.0.0.4 Serial2/2
r4#sh ip os nei
Neighbor ID Pri State Dead Time Address Interface
3.3.3.3 0 FULL/ - 00:00:39 34.0.0.3 Serial2/1
查看OSPF链路数据库信息
r4#sh ip os da
OSPF Router with ID (4.4.4.4) (Process ID 100)
Router Link States (Area 2)
Link ID ADV Router Age Seq# Checksum Link count
3.3.3.3 3.3.3.3 953 0x80000002 0x00151E 2
4.4.4.4 4.4.4.4 942 0x80000002 0x00C14C 3
Summary Net Link States (Area 2)
Link ID ADV Router Age Seq# Checksum
1.1.1.1 3.3.3.3 975 0x80000001 0x00109B
2.2.2.2 3.3.3.3 975 0x80000001 0x005F88
3.3.3.3 3.3.3.3 975 0x80000001 0x00AE75
12.0.0.0 3.3.3.3 975 0x80000001 0x00970D
23.0.0.0 3.3.3.3 975 0x80000001 0x008554
r2#sh ip os nei
Neighbor ID Pri State Dead Time Address Interface
3.3.3.3 0 FULL/ - 00:00:34 23.0.0.3 Serial2/2
1.1.1.1 0 FULL/ - 00:00:39 12.0.0.1 Serial2/1
r2#
r2#sh ip os da
OSPF Router with ID (2.2.2.2) (Process ID 100)
Router Link States (Area 0)
Link ID ADV Router Age Seq# Checksum Link count
2.2.2.2 2.2.2.2 1017 0x80000003 0x008EAD 3
3.3.3.3 3.3.3.3 998 0x80000003 0x002C07 3
Summary Net Link States (Area 0)
Link ID ADV Router Age Seq# Checksum
1.1.1.1 2.2.2.2 1048 0x80000001 0x00AB44
4.4.4.4 3.3.3.3 962 0x80000001 0x0003DC
12.0.0.0 2.2.2.2 1048 0x80000001 0x0033B5
34.0.0.0 3.3.3.3 994 0x80000001 0x00F5D8
Router Link States (Area 1)
Link ID ADV Router Age Seq# Checksum Link count
1.1.1.1 1.1.1.1 1057 0x80000003 0x00F46F 3
2.2.2.2 2.2.2.2 1048 0x80000002 0x00561E 2
Summary Net Link States (Area 1)
Link ID ADV Router Age Seq# Checksum
2.2.2.2 2.2.2.2 1033 0x80000001 0x00FA31
3.3.3.3 2.2.2.2 1003 0x80000001 0x004F98
4.4.4.4 2.2.2.2 962 0x80000001 0x00A3FF
23.0.0.0 2.2.2.2 1044 0x80000001 0x00A33A
34.0.0.0 2.2.2.2 993 0x80000001 0x0096FB
查看路由表
r1#sh ip ro
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
34.0.0.0/24 is subnetted, 1 subnets
O IA 34.0.0.0 [110/192] via 12.0.0.2, 00:17:00, Serial2/1
1.0.0.0/24 is subnetted, 1 subnets
C 1.1.1.0 is directly connected, Loopback0
2.0.0.0/32 is subnetted, 1 subnets
O IA 2.2.2.2 [110/65] via 12.0.0.2, 00:17:41, Serial2/1
3.0.0.0/32 is subnetted, 1 subnets
O IA 3.3.3.3 [110/129] via 12.0.0.2, 00:17:10, Serial2/1
4.0.0.0/32 is subnetted, 1 subnets
O IA 4.4.4.4 [110/193] via 12.0.0.2, 00:16:29, Serial2/1
23.0.0.0/24 is subnetted, 1 subnets
O IA 23.0.0.0 [110/128] via 12.0.0.2, 00:17:50, Serial2/1
12.0.0.0/24 is subnetted, 1 subnets
C 12.0.0.0 is directly connected, Serial2/1
r3#sh ip ro
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
34.0.0.0/24 is subnetted, 1 subnets
C 34.0.0.0 is directly connected, Serial2/2
1.0.0.0/32 is subnetted, 1 subnets
O IA 1.1.1.1 [110/129] via 23.0.0.2, 00:16:48, Serial2/1
2.0.0.0/32 is subnetted, 1 subnets
O 2.2.2.2 [110/65] via 23.0.0.2, 00:17:20, Serial2/1
3.0.0.0/24 is subnetted, 1 subnets
C 3.3.3.0 is directly connected, Loopback0
4.0.0.0/32 is subnetted, 1 subnets
O 4.4.4.4 [110/65] via 34.0.0.4, 00:16:48, Serial2/2
23.0.0.0/24 is subnetted, 1 subnets
C 23.0.0.0 is directly connected, Serial2/1
12.0.0.0/24 is subnetted, 1 subnets
O IA 12.0.0.0 [110/128] via 23.0.0.2, 00:16:49, Serial2/1
r3#