华为ospf配置命令_华为设备从最简单的OSPF配置开始,看完就明白了

华为设备基础的OSPF配置

【实验原理】

一、OSPF单区域实验配置

1 组网及业务描述

a807a9d3e6bbc86817a4dbda045c9e82.png

l 四台路由器RTA, RTB, RTC以及RTD同时运行OSPF,并且同属于同一区域Area 0

l 路由器与路由器之间通过运行OSPF,实现两两之间的相互通信。

l 所有路由器的版本是VRP 3.30,RELEASE 0008

实验步骤

(1)指定RouterID:在system-view视图下,指定一个Router ID,在通常情况下都采用Loopback地址来作为Router ID。

(2)运行OSPF: 在system-view 视图下,运行OSPF,采用默认的OSPF进程1。

(3)创建区域:在OSPF视图下创建一个骨干区域Area 0。

(4)通告网络:在Area视图下通告相应的网络,不同的路由器通告网络也会相对不同,如在路由器RTB上,应通告10.1.1.0和192.2.2.0。

参考配置

(1)端口配置

配置RTA

system-view

[Quidway]sysname RTA

[RTA]interface loopback 0

[RTA-LoopBack0]ip address 1.1.1.1 255.255.255.255

[RTA-LoopBack0]quit

[RTA]interface ethernet 0/0

[RTA-Ethernet0/0]ip address 10.1.1.1 255.255.255.252

[RTA-Ethernet0/0]quit

[RTA]interface serial 2/0

[RTA-Serial2/0]ip address 192.1.1.1 255.255.255.252

[RTA-Serial2/0]quit

配置RTB

system-view

[Quidway]sysname RTB

[RTB]interface loopback 0

[RTB-LoopBack0]ip address 2.2.2.2 255.255.255.255

[RTB-LoopBack0]quit

[RTB]interface Ethernet 0/0

[RTB-Ethernet0/0]ip address 10.1.1.2 255.255.255.252

[RTB-Ethernet0/0]quit

[RTB]interface serial 2/0

[RTB-Serial2/0]ip address 192.2.2.2 255.255.255.252

[RTB-Serial2/0]quit

配置RTC

system-view

[Quidway]sysname RTC

[RTC]interface loopback 0

[RTC-LoopBack0]ip address 3.3.3.3 255.255.255.255

[RTC-LoopBack0]quit

[RTC]interface Ethernet 0/0

[RTC-Ethernet2/0]ip address 10.2.2.2 255.255.255.252

[RTC-Ethernet2/0]quit

[RTC]interface serial 2/0

[RTC-Serial2/0]ip address 192.2.2.1 255.255.255.252

[RTC-Serial2/0]quit

配置RTD

system-view

[Quidway]sysname RTD

[RTD]interface loopback 0

[RTD-LoopBack0]ip address 4.4.4.4 255.255.255.255

[RTD-LoopBack0]quit

[RTD]interface ethernet 0/0

[RTD-Ethernet0/0]ip address 10.2.2.1 255.255.255.252

[RTD-Ethernet0/0]quit

[RTD]interface serial 2/0

[RTD-Serial2/0]ip address 192.1.1.2 255.255.255.252

[RTD-Serial2/0]quit

(2)OSPF配置

配置RTA

[RTA]router id 1.1.1.1 指定Router ID

[RTA]ospf 运行OSPF

[RTA-ospf-1]area 0 创建区域0

[RTA-ospf-1-area-0.0.0.0]net 10.1.1.0 0.0.0.3 在区域0视图下通告网络10.1.1.0

[RTA-ospf-1-area-0.0.0.0]net 192.1.1.0 0.0.0.3 通告网络192.1.1.0

[RTA-ospf-1-area-0.0.0.0]net 1.1.1.1 0.0.0.0 通告网络1.1.1.1

配置RTB

[RTB]router id 2.2.2.2 指定Router ID

[RTB]ospf 运行OSPF

[RTB-ospf-1]area 0 创建区域0

[RTB-ospf-1-area-0.0.0.0]net 10.1.1.0 0.0.0.3 在区域0视图下通告网络10.1.1.0

[RTB-ospf-1-area-0.0.0.0]net 192.2.2.0 0.0.0.3 通告网络192.2.2.0

[RTB-ospf-1-area-0.0.0.0]net 2.2.2.2 0.0.0.0 通告网络2.2.2.2

配置RTC

[RTC]router id 3.3.3.3 指定Router ID

[RTC]ospf 运行OSPF

[RTC-ospf-1]area 0 创建区域0

[RTC-ospf-1-area-0.0.0.0]net 10.2.2.0 0.0.0.3 通告10.2.2.0

[RTC-ospf-1-area-0.0.0.0]net 192.2.2.0 0.0.0.3 在区域0视图下通告网络192.2.2.0

[RTC-ospf-1-area-0.0.0.0]net 3.3.3.3 0.0.0.0 通告网络3.3.3.3

配置RTD

指定Router ID

[RTD]router id 4.4.4.4 指定Router ID

[RTD]ospf 运行OSPF

[RTD-ospf-1]area 0 创建区域0

[RTD-ospf-1-area-0.0.0.0]net 10.2.2.0 0.0.0.3 在区域0视图下通告网络10.2.2.0

[RTD-ospf-1-area-0.0.0.0]net 192.1.1.0 0.0.0.3 通告网络192.1.1.0

[RTD-ospf-1-area-0.0.0.0]net 4.4.4.4 0.0.0.0 通告网络4.4.4.4

结果验证

(1)每台设备的各网络都可以相互访问(通过Ping命令测试)

[RTA]ping -a 1.1.1.1 3.3.3.3

PING 3.3.3.3: 56 data bytes, press CTRL_C to break

Reply from 3.3.3.3: bytes=56 Sequence=1 ttl=254 time=29 ms

Reply from 3.3.3.3: bytes=56 Sequence=2 ttl=254 time=29 ms

Reply from 3.3.3.3: bytes=56 Sequence=3 ttl=254 time=29 ms

Reply from 3.3.3.3: bytes=56 Sequence=4 ttl=254 time=28 ms

Reply from 3.3.3.3: bytes=56 Sequence=5 ttl=254 time=28 ms

--- 3.3.3.3 ping statistics ---

5 packet(s) transmitted

5 packet(s) received

0.00% packet loss

round-trip min/avg/max = 28/28/29 ms

(2)通过display ip routing-table 查看路由表。

[RTA]dis ip routing-table

Routing Table: public net

Destination/Mask Protocol Pre Cost Nexthop Interface

1.1.1.1/32 DIRECT 0 0 127.0.0.1 InLoopBack0

2.2.2.2/32 OSPF 10 2 10.1.1.2 Ethernet0/0

3.3.3.3/32 OSPF 10 1564 10.1.1.2 Ethernet0/0

192.1.1.2 Serial2/0

4.4.4.4/32 OSPF 10 1563 192.1.1.2 Serial2/0

10.1.1.0/30 DIRECT 0 0 10.1.1.1 Ethernet0/0

10.1.1.1/32 DIRECT 0 0 127.0.0.1 InLoopBack0

10.2.2.0/30 OSPF 10 1563 192.1.1.2 Serial2/0

127.0.0.0/8 DIRECT 0 0 127.0.0.1 InLoopBack0

127.0.0.1/32 DIRECT 0 0 127.0.0.1 InLoopBack0

192.1.1.0/30 DIRECT 0 0 192.1.1.1 Serial2/0

192.1.1.1/32 DIRECT 0 0 127.0.0.1 InLoopBack0

192.1.1.2/32 DIRECT 0 0 192.1.1.2 Serial2/0

192.2.2.0/30 OSPF 10 1563 10.1.1.2 Ethernet0/0

[RTB]dis ip routing-table

Routing Table: public net

Destination/Mask Protocol Pre Cost Nexthop Interface

1.1.1.1/32 OSPF 10 2 10.1.1.1 Ethernet0/0

2.2.2.2/32 DIRECT 0 0 127.0.0.1 InLoopBack0

3.3.3.3/32 OSPF 10 1563 192.2.2.1 Serial2/0

4.4.4.4/32 OSPF 10 1564 10.1.1.1 Ethernet0/0

192.2.2.1 Serial2/0

10.1.1.0/30 DIRECT 0 0 10.1.1.2 Ethernet0/0

10.1.1.2/32 DIRECT 0 0 127.0.0.1 InLoopBack0

10.2.2.0/30 OSPF 10 1563 192.2.2.1 Serial2/0

127.0.0.0/8 DIRECT 0 0 127.0.0.1 InLoopBack0

127.0.0.1/32 DIRECT 0 0 127.0.0.1 InLoopBack0

192.1.1.0/30 OSPF 10 1563 10.1.1.1 Ethernet0/0

192.2.2.0/30 DIRECT 0 0 192.2.2.2 Serial2/0

192.2.2.1/32 DIRECT 0 0 192.2.2.1 Serial2/0

192.2.2.2/32 DIRECT 0 0 127.0.0.1 InLoopBack0

[RTC]dis ip routing-table

Routing Table: public net

Destination/Mask Protocol Pre Cost Nexthop Interface

1.1.1.1/32 OSPF 10 1564 10.2.2.1 Ethernet0/0

192.2.2.2 Serial2/0

2.2.2.2/32 OSPF 10 1563 192.2.2.2 Serial2/0

3.3.3.3/32 DIRECT 0 0 127.0.0.1 InLoopBack0

4.4.4.4/32 OSPF 10 2 10.2.2.1 Ethernet0/0

10.1.1.0/30 OSPF 10 1563 192.2.2.2 Serial2/0

10.2.2.0/30 DIRECT 0 0 10.2.2.2 Ethernet0/0

10.2.2.2/32 DIRECT 0 0 127.0.0.1 InLoopBack0

127.0.0.0/8 DIRECT 0 0 127.0.0.1 InLoopBack0

127.0.0.1/32 DIRECT 0 0 127.0.0.1 InLoopBack0

192.1.1.0/30 OSPF 10 1563 10.2.2.1 Ethernet0/0

192.2.2.0/30 DIRECT 0 0 192.2.2.1 Serial2/0

192.2.2.1/32 DIRECT 0 0 127.0.0.1 InLoopBack0

192.2.2.2/32 DIRECT 0 0 192.2.2.2 Serial2/0

[RTD]dis ip routing-table

Routing Table: public net

Destination/Mask Protocol Pre Cost Nexthop Interface

1.1.1.1/32 OSPF 10 1563 192.1.1.1 Serial2/0

2.2.2.2/32 OSPF 10 1564 10.2.2.2 Ethernet0/0

192.1.1.1 Serial2/0

3.3.3.3/32 OSPF 10 2 10.2.2.2 Ethernet0/0

4.4.4.4/32 DIRECT 0 0 127.0.0.1 InLoopBack0

10.1.1.0/30 OSPF 10 1563 192.1.1.1 Serial2/0

10.2.2.0/30 DIRECT 0 0 10.2.2.1 Ethernet0/0

10.2.2.1/32 DIRECT 0 0 127.0.0.1 InLoopBack0

127.0.0.0/8 DIRECT 0 0 127.0.0.1 InLoopBack0

127.0.0.1/32 DIRECT 0 0 127.0.0.1 InLoopBack0

192.1.1.0/30 DIRECT 0 0 192.1.1.2 Serial2/0

192.1.1.1/32 DIRECT 0 0 192.1.1.1 Serial2/0

192.1.1.2/32 DIRECT 0 0 127.0.0.1 InLoopBack0

192.2.2.0/30 OSPF 10 1563 10.2.2.2 Ethernet0/0

& 说明:

可以看到各路由器都通过OSPF学习到其它的路由信息,为网络提供了连通性,另外从路由表里也可以看到OSPF可以支持等价路由。如RTD上,到达2.2.2.2/32的数据可以送往10.2.2.2,也可以送往192.1.1.1。

(3)通过display ospf routing查看OSPF的路由表;

[RTA]dis ospf routing

OSPF Process 1 with Router ID 1.1.1.1

Routing Tables

Routing for Network

Destination Cost Type NextHop AdvRouter Area

10.1.1.0/30 1 Net 10.1.1.1 1.1.1.1 0.0.0.0

192.2.2.0/30 1563 Stub 10.1.1.2 2.2.2.2 0.0.0.0

2.2.2.2/32 2 Stub 10.1.1.2 2.2.2.2 0.0.0.0

1.1.1.1/32 1 Stub 1.1.1.1 1.1.1.1 0.0.0.0

192.1.1.0/30 1562 Stub 192.1.1.1 1.1.1.1 0.0.0.0

10.2.2.0/30 1563 Net 192.1.1.2 3.3.3.3 0.0.0.0

4.4.4.4/32 1563 Stub 192.1.1.2 4.4.4.4 0.0.0.0

3.3.3.3/32 1564 Stub 192.1.1.2 3.3.3.3 0.0.0.0

10.1.1.2

Total Nets: 8

Intra Area: 8 Inter Area: 0 ASE: 0 NSSA: 0

(4)通过display ospf lsdb查看链路状态数据库;

[RTA]dis ospf lsdb

OSPF Process 1 with Router ID 1.1.1.1

Link State Database

Area: 0.0.0.0

Type LinkState ID AdvRouter Age Len Sequence Metric Where

Stub 192.2.2.0 2.2.2.2 149 24 0 0 SpfTree

Stub 2.2.2.2 2.2.2.2 136 24 0 0 SpfTree

Stub 4.4.4.4 4.4.4.4 162 24 0 0 SpfTree

Stub 192.1.1.0 1.1.1.1 162 24 0 0 SpfTree

Stub 1.1.1.1 1.1.1.1 125 24 0 0 SpfTree

Stub 3.3.3.3 3.3.3.3 149 24 0 0 SpfTree

Rtr 2.2.2.2 2.2.2.2 137 72 80000009 0 Clist

Rtr 4.4.4.4 4.4.4.4 163 72 80000009 0 Clist

Rtr 1.1.1.1 1.1.1.1 125 72 80000009 0 SpfTree

Rtr 3.3.3.3 3.3.3.3 151 72 80000009 0 Clist

Net 10.1.1.1 1.1.1.1 241 32 80000001 0 SpfTree

Net 10.2.2.2 3.3.3.3 189 32 80000001 0 SpfTree

说明:

OSPF通过正确的LSA来描述一个区域的网络拓扑情况。这里需要注意的是数据库的类型(Type)里的每种类型分别都代表着OSPF里的不同类型的LSA,下面列出常见的LAS:

Stub:连接到一个末梢网络的路由器LSA。(注:这里的末梢网络指的是边缘网络,与Stub区域并不是同一个概念。)

Rtr:路由器LSA

Net:网络LSA

Snet:网络汇总LSA

ASB: 自治系统边界路由器汇总LSA

ASE:自治系统外部LSA

NSSA:NSSA外部LSA

(5)通过display ospf brief命令查看OSPF的总结信息;

[RTA]dis ospf brief

OSPF Process 1 with Router ID 1.1.1.1

OSPF Protocol Information

RouterID: 1.1.1.1

Spf-schedule-interval: 5

Routing preference: Inter/Intra: 10 External: 150

Default ASE parameters: Metric: 1 Tag: 1 Type: 2

SPF computation count: 10

Area Count: 1 Nssa Area Count: 0

Area 0.0.0.0:

Authtype: none Flags: <>

SPF scheduled: <>

Interface: 10.1.1.1 (Ethernet0/0)

Cost: 1 State: DR Type: Broadcast

Priority: 1

Designated Router: 10.1.1.1

Backup Designated Router: 10.1.1.2

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

Interface: 192.1.1.1 (Serial2/0) --> 192.1.1.2

Cost: 1562 State: PtoP Type: PointToPoint

Priority: 1

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

Interface: 1.1.1.1 (LoopBack0) --> 1.1.1.1

Cost: 1 State: PtoP Type: PointToPoint

Priority: 1

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