动态路由协议,OSPF协议基础配置,一分钟了解下

2024-04-10 15:30:00

一、目的

掌握单区域 OSPF 的配置方法

掌握 OSPF 区域认证的配置方法

修 改 OSPF 的 Loopback 的 32 位主机路由

掌握对 OSPF 接口代价值进行修改的方法

掌握 OSPF 中 Silent-interface 的配置方法

掌握使用 Display 查看 OSPF 各种状态的方法

掌握使用 Debug 命令查看 OSPF 邻接关系和进行故障排除的方法

二、拓扑

三、步骤

1、单区域的 OSPF,IP地址配置忽略

2、配置单区域(area0 )的 OSPF

R1上配置:

[R1]ospf 1 router-id 11.1.1.1 //配置 OSPF 的进程号以及 route-ID

[R1-ospf-1]area 0 //进入到区域 0 里面。

[R1-ospf-1-area-0.0.0.0]network 12.1.1.1 0.0.0.0 //精确宣告一个 IP 地址。

[R1-ospf-1-area-0.0.0.0]network 11.1.1.1 0.0.0.0

[R1-ospf-1-area-0.0.0.0]authentication-mode md5 1 cipher yeslab // 基于区域的

MD5 认证

在 R2 上配置:

[R2]ospf 1 router-id 22.1.1.1

[R2-ospf-1]area 0

[R2-ospf-1-area-0.0.0.0]network 12.1.1.2 0.0.0.0

[R2-ospf-1-area-0.0.0.0]network 23.1.1.2 0.0.0.0

[R2-ospf-1-area-0.0.0.0]network 22.1.1.1 0.0.0.0

[R2-ospf-1-area-0.0.0.0]authentication-mode md5 1 cipher huawei

在 R3 上去配置:

[R3]ospf 1 router-id 33.1.1.1

[R3-ospf-1-area-0.0.0.0]network 33.1.1.1 0.0.0.0

[R3-ospf-1-area-0.0.0.0]network 23.1.1.3 0.0.0.0

[R3-ospf-1-area-0.0.0.0]authentication-mode md5 1 cipher huawei

四、检查路由表

1、查看R1的路由表:

[R1]display ip routing protocol ospf

Destination/Mask Proto Pre Cost Flags NextHop Interface

22.1.1.1/32 OSPF 10 1 D 12.1.1.2 Ethernet0/0/0

23.1.1.0/24 OSPF 10 2 D 12.1.1.2 Ethernet0/0/0

33.1.1.1/32 OSPF 10 2 D 12.1.1.2 Ethernet0/0/0

2、在 R2 上查看:

[R2]display ip routing protocol ospf

Destination/Mask Proto Pre Cost Flags NextHop Interface

11.1.1.1/32 OSPF 10 1 D 12.1.1.1 Ethernet0/0/0

33.1.1.1/32 OSPF 10 1 D 23.1.1.3 Ethernet0/0/1

3、在 R3 上查看:

[R3]display ip routing protocol ospf

Destination/Mask Proto Pre Cost Flags NextHop Interface

11.1.1.1/32 OSPF 10 2 D 23.1.1.2 Ethernet0/0/0

12.1.1.0/24 OSPF 10 2 D 23.1.1.2 Ethernet0/0/0

22.1.1.1/32 OSPF 10 1 D 23.1.1.2 Ethernet0/0/0

使用 display ospf brief 命令查看 OSPF 运行的基本信息:

[R1]display ospf brief

......

Area: 0.0.0.0 (MPLS TE not enabled)

Authtype: MD5 Area flag: Normal //区域 0 的认证类型

SPF scheduled Count: 8

ExChange/Loading Neighbors: 0

Router ID conflict state: Normal

Interface: 12.1.1.1 (Ethernet0/0/0) //接口的的开销,状态,接口网络类型

Cost: 1 State: DR Type: Broadcast MTU: 1500

Priority: 1

Designated Router: 12.1.1.1

Backup Designated Router: 12.1.1.2

Timers: Hello 10 , Dead 40 , Poll 120 , Retransmit 5 , Transmit Delay 1

Interface: 11.1.1.1 (LoopBack1)

Cost: 0 State: P-2-P Type: P2P MTU: 1500

Timers: Hello 10 , Dead 40 , Poll 120 , Retransmit 5 , Transmit Delay 1

4、使用 display ospf brief 命令查看 OSPF 运行的基本信息

[R1]display ospf brief

Area: 0.0.0.0 (MPLS TE not enabled)

Authtype: MD5 Area flag: Normal //区域 0 的认证类型

SPF scheduled Count: 8

ExChange/Loading Neighbors: 0

Router ID conflict state: Normal

Interface: 12.1.1.1 (Ethernet0/0/0) //接口的的开销,状态,接口网络类型

Cost: 1 State: DR Type: Broadcast MTU: 1500

Priority: 1

Designated Router: 12.1.1.1

Backup Designated Router: 12.1.1.2

Timers: Hello 10 , Dead 40 , Poll 120 , Retransmit 5 , Transmit Delay 1

Interface: 11.1.1.1 (LoopBack1)

Cost: 0 State: P-2-P Type: P2P MTU: 1500

Timers: Hello 10 , Dead 40 , Poll 120 , Retransmit 5 , Transmit Delay 1

查看邻居关系:

[R1]display ospf peer brief

OSPF Process 1 with Router ID 11.1.1.1

Peer Statistic Information

----------------------------------------------------------------------------

Area Id Interface Neighbor id State

0.0.0.0 Ethernet0/0/0 22.1.1.1 Full

----------------------------------------------------------------------------

R1 上能看到 R2 这个邻居,有邻居的 route-ID, 状态,本地接口和区域等。

查看 LSDB 表项:

[R1]display ospf lsdb

OSPF Process 1 with Router ID 11.1.1.1

Link State Database

Area: 0.0.0.0

Type LinkState ID AdvRouter Age Len Sequence Metric

Router 33.1.1.1 33.1.1.1 668 48 80000004 0

Router 22.1.1.1 22.1.1.1 668 60 80000009 1

Router 11.1.1.1 11.1.1.1 726 48 80000006 1

Network 23.1.1.2 22.1.1.1 668 32 80000001 0

Network 12.1.1.1 11.1.1.1 726 32 80000001 0

//以上输出表示能看到一类的和 2 类的 LSA

查看一条详细的内容

[R1]display ospf lsdb router 33.1.1.1

OSPF Process 1 with Router ID 11.1.1.1

Area: 0.0.0.0

Link State Database

Type : Router

Ls id : 33.1.1.1

Adv rtr : 33.1.1.1

Ls age : 694

Len : 48

Options : E

seq# : 80000004

chksum : 0xc9d2

Link count: 2

* Link ID: 33.1.1.1

Data : 255.255.255.255

Link Type: StubNet

Metric : 0

Priority : Medium

* Link ID: 23.1.1.2

Data : 23.1.1.3

Link Type: TransNet

Metric : 1

//以上输出表示 R3 通告了二项信息,一个是回环回,一个是连接 R2 的接口