R1(config)#interface s2/1
R1(config-if)#ip address 12.0.0.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#interface loopback0
R1(config-if)#ip address 172.16.1.1 255.255.255.0
R1(config-if)#interface loopback1
R1(config-if)#ip address 172.16.2.1 255.255.255.0
R1(config-if)#interface loopback 2
R1(config-if)#ip address 172.16.3.1 255.255.255.0
R1(config-if)#interface loopback 3
R1(config-if)#ip address 172.16.4.1 255.255.255.0
R2(config-if)#ip address 12.0.0.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#interface s2/2
R2(config-if)#ip address 23.0.0.2 255.255.255.0
R2(config-if)#no shutdown
R3(config)#interface serial2/1
R3(config-if)#ip address 23.0.0.3 255.255.255.0
R3(config-if)#no shutdown
R3(config-if)#interface serial 2/2
R3(config-if)#ip address 34.0.0.3 255.255.255.0
R3(config-if)#no shutdown
R4(config-if)#ip address 34.0.0.4 255.255.255.0
R4(config-if)#no shutdown
R1(config)#router ospf 100
R1(config-router)#network 172.16.1.1 0.0.0.255 area 1
R1(config-router)#network 172.16.2.1 0.0.0.255 area 1
R1(config-router)#network 172.16.4.1 0.0.0.255 area 1
R1(config-router)#network 12.0.0.0 0.0.0.255 area 1
R1(config-router)#log-adjacency-changes //打开OSPF邻居状态日志
R2(config-router)#network 12.0.0.0 0.0.0.255 area 1
R2(config-router)#network 23.0.0.0 0.0.0.255 area 0
R2(config-router)#log-adjacency-changes
R3(config-router)#network 23.0.0.0 0.0.0.255 area 0
R3(config-router)#network 34.0.0.0 0.0.0.255 area 2
R4(config-router)#network 34.0.0.0 0.0.0.255 area 2
R2(config-router)#area 1 range 172.16.0.0 255.255.248.0
R2(config-if)#ip ospf message-digest-key 1 md5 cisco //定义认证密钥
R2(config-if)#exit
R2(config)#router ospf 100
R2(config-router)#area 0 authentication message-digest //在区域0中开启认证
R3(config-if)#router ospf 100
R3(config-router)#area 0 authentication message-digest
R3(config-if)#ip ospf hello-interval 5
R4(config-if)#ip ospf hello-interval 5
R4(config-if)#ip ospf dead-interval 20
R4(config-if)#ip ospf cost 80
Serial2/1 is up, line protocol is up
Internet Address 34.0.0.4/24, Area 2
Process ID 100, Router ID 34.0.0.4, Network Type POINT_TO_POINT, Cost: 80
Transmit Delay is 1 sec, State POINT_TO_POINT,
Timer intervals configured, Hello 5, Dead 20, Wait 20, Retransmit 5
Hello due in 00:00:00
Index 1/1, flood queue length 0
Next 0×0(0)/0×0(0)
Last flood scan length is 1, maximum is 1
Last flood scan time is 0 msec, maximum is 0 msec
Neighbor Count is 1, Adjacent neighbor count is 1
Adjacent with neighbor 34.0.0.3
show ip protocol | 显示路由器上运行的所有路由选择协议 |
show ip router | 显示完整的路由表 |
show ip ospf | 显示ospf路由进程的基本信息 |
show ip ospf interface | 显示接口的ospf相关信息 |
show ip ospf interface fastethernet0/0 | 显示特定接口F0/0的ospf信息 |
show ip ospf border-rotuers | 显示所有边界路由信息 |
show ip ospf neighbor | 显示ospf的邻居表 |
show ip ospf neighbor detail | 显示ospf邻居的详细信息 |
show ip ospf database | 显示ospf的数据库 |