1.基本配置
配置相应的IP地址,并检测各直连链路的连通性。
2.部署单区域OSPF网络
首先使用命令ospf命令创建并运行OSPF
[R1]ospf 1
其中1代表的是进程号,如果没有写明进程号,则默认是1
接着使用area命令指定运行OSPF协议的接口和接口所属的协议。
[R1-ospf-1]area 0
[R1-ospf-1-area-0.0.0.0]network 172.16.1.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]network 172.16.10.0 0.0.0.255
[R1-ospf-1-area-0.0.0.0]network 172.16.20.0 0.0.0.255
使用display ospf interface命令检查OSPF接口通告是否正确
<R1>dis ospf int
OSPF Process 1 with Router ID 172.16.1.254
Interfaces
Area: 0.0.0.0 (MPLS TE not enabled)
IP Address Type State Cost Pri DR BDR
172.16.1.254 Broadcast DR 1 1 172.16.1.254 0.0.0.0
172.16.10.1 Broadcast DR 1 1 172.16.10.1 0.0.0.0
172.16.20.1 Broadcast DR 1 1 172.16.20.1 0.0.0.0
[R2]ospf 1
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 172.16.2.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]network 172.16.30.0 0.0.0.255
[R2-ospf-1-area-0.0.0.0]network 172.16.10.0 0.0.0.255
[R3]ospf 1
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 172.16.3.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]network 172.16.20.0 0.0.0.255
[R3-ospf-1-area-0.0.0.0]network 172.16.30.0 0.0.0.255
3.检查OSPF单区域的配置结果
以R1为例,使用display ospf peer命令查看OSPF邻居状态。
<R1>dis ospf peer
OSPF Process 1 with Router ID 172.16.1.254
Neighbors
Area 0.0.0.0 interface 172.16.10.1(GigabitEthernet0/0/0)'s neighbors
Router ID: 172.16.10.2 Address: 172.16.10.2
State: Full Mode:Nbr is Master Priority: 1
DR: 172.16.10.1 BDR: 172.16.10.2 MTU: 0
Dead timer due in 33 sec
Retrans timer interval: 5
Neighbor is up for 00:03:41
Authentication Sequence: [ 0 ]
Neighbors
Area 0.0.0.0 interface 172.16.20.1(GigabitEthernet0/0/1)'s neighbors
Router ID: 172.16.20.3 Address: 172.16.20.3
State: Full Mode:Nbr is Master Priority: 1
DR: 172.16.20.1 BDR: 172.16.20.3 MTU: 0
Dead timer due in 33 sec
Retrans timer interval: 5
Neighbor is up for 00:02:29
Authentication Sequence: [ 0 ]
通过此命令可以查看很多内容:通过Router-ID查看邻居路由器的标识;通过Address可以查看邻居的OSPF接口的IP地址;
通过Sate可以查看母线与该路由器的OSPF邻居的状态;通过Priority可以查看当前该邻居OSPF接口的DR优先等级等
系统视图下,使用display ip routing-table protocol ospf查看ospf路由表
[R1]dis ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : OSPF
Destinations : 3 Routes : 4
OSPF routing table status : <Active>
Destinations : 3 Routes : 4
Destination/Mask Proto Pre Cost Flags NextHop Interface
172.16.2.0/24 OSPF 10 2 D 172.16.10.2 GigabitEthernet 0/0/0
172.16.3.0/24 OSPF 10 2 D 172.16.20.3 GigabitEthernet 0/0/1
172.16.30.0/24 OSPF 10 2 D 172.16.10.2 GigabitEthernet 0/0/0
OSPF 10 2 D 172.16.20.3 GigabitEthernet 0/0/1
OSPF routing table status : <Inactive>
Destinations : 0 Routes : 0
通过此路由表可以观察到:Destination/Mask标识了目的网段的前缀及掩码,Proto标识了此路由信息使用过OSPF协议获取的,
Pre标识了路由优先级,Cost 标识了开销值,NextHop 标识了下一跳地址, Interface标识了此前缀的出接口。