admin 管理员组

文章数量: 1087135


2024年1月5日发(作者:计算机汇编语言程序设计)

华为OSPF单区域、多区域配置、时间参数

DRBDR选举 重分布路由与认证演示

一、 实验拓扑

二、 基本配置

R1:

interface Serial1/0/0

ip address 10.0.12.1 255.255.255.0

interface GigabitEthernet0/0/0

ip address 10.0.13.1 255.255.255.0

interface LoopBack0

ip address 10.0.1.1 255.255.255.0

R2:

interface Serial1/0/0

ip address 10.0.12.2 255.255.255.0

interface LoopBack0

ip address 10.0.2.2 255.255.255.0

R3:

interface GigabitEthernet0/0/0

ip address 10.0.13.3 255.255.255.0

interface LoopBack0

ip address 10.0.3.3 255.255.255.0

interface LoopBack1

ip address 172.16.0.1 255.255.255.0

测试:

[R1]ping -c 2 10.0.12.2

PING 10.0.12.2: 56 data bytes, press CTRL_C to break

Reply from 10.0.12.2: bytes=56 Sequence=1 ttl=255 time=50 ms

Reply from 10.0.12.2: bytes=56 Sequence=2 ttl=255 time=10 ms

[R1]ping -c 2 10.0.13.3

PING 10.0.13.3: 56 data bytes, press CTRL_C to break

Reply from 10.0.13.3: bytes=56 Sequence=1 ttl=255 time=30 ms

Reply from 10.0.13.3: bytes=56 Sequence=2 ttl=255 time=10 ms

三、 OSPF 配置

[R1]ospf 1 router-id 10.0.1.1 ====启用 OPSF 进程,默认进程 ID 为 1.进程 ID 只具有本地意义,所以同一区域的不同路由器

可以使用相同或者不同进程 ID。

[R1-ospf-1]are 0

[R1-ospf-1-area-0.0.0.0]network 10.0.1.0 0.0.0.255 =====network 后面配置反掩码

[R1-ospf-1-area-0.0.0.0]network 10.0.13.0 0.0.0.255

[R1-ospf-1-area-0.0.0.0]network 10.0.12.0 0.0.0.255

[R2]ospf 10 router-id 10.0.2.2

[R2-ospf-10]area 0

[R2-ospf-10-area-0.0.0.0]network 10.0.12.0 0.0.0.255

[R2-ospf-10-area-0.0.0.0]network 10.0.2.0 0.0.0.255

[R3]ospf 100 router-id 10.0.3.3

[R3-ospf-100]area 0

[R3-ospf-100-area-0.0.0.0]network 10.0.13.0 0.0.0.255

[R3-ospf-100-area-0.0.0.0]network 10.0.3.0 0.0.0.255

R1>display ip routing-table protocol ospf ====查看路由表中 OSPF 路由信息

Route Flags: R - relay, D - download to fib

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

Public routing table : OSPF

Destinations : 2 Routes : 2

OSPF routing table status :

Destinations : 2 Routes : 2

Destination/Mask Proto Pre Cost Flags NextHop Interface

10.0.2.2/32 OSPF 10 48 D 10.0.12.2 Serial1/0/0

10.0.3.3/32 OSPF 10 1 D 10.0.13.3 GigabitEthernet0/0/0

OSPF routing table status :

Destinations : 0 Routes : 0

测试:

ping -c 1 10.0.2.2

PING 10.0.2.2: 56 data bytes, press CTRL_C to break

Reply from 10.0.2.2: bytes=56 Sequence=1 ttl=255 time=10 ms

--- 10.0.2.2 ping statistics ---

1 packet(s) transmitted

1 packet(s) received

0.00% packet loss

round-trip min/avg/max = 10/10/10 ms

ping -c 1 10.0.3.3

PING 10.0.3.3: 56 data bytes, press CTRL_C to break

Reply from 10.0.3.3: bytes=56 Sequence=1 ttl=255 time=10 ms

--- 10.0.3.3 ping statistics ---

1 packet(s) transmitted

1 packet(s) received

0.00% packet loss

round-trip min/avg/max = 10/10/10 ms

display ospf peer ====显示 OSPF 邻居详细信息

OSPF Process 1 with Router ID 10.0.12.1

Neighbors

Area 0.0.0.0 interface 10.0.12.1(Serial1/0/0)'s neighbors

Router ID: 10.0.2.2 Address: 10.0.12.2

State: Full Mode:Nbr is Slave Priority: 1

DR: None BDR: None MTU: 0

Dead timer due in 32 sec

Retrans timer interval: 5

Neighbor is up for 00:09:52

Authentication Sequence: [ 0 ]

Neighbors

Area 0.0.0.0 interface 10.0.13.1(GigabitEthernet0/0/0)'s neighbors

Router ID: 10.0.3.3 Address: 10.0.13.3

State: Full Mode:Nbr is Slave Priority: 1

DR: 10.0.13.1 BDR: 10.0.13.3 MTU: 0

Dead timer due in 34 sec

Retrans timer interval: 5

Neighbor is up for 00:06:50

Authentication Sequence: [ 0 ]

display ospf peer brief ====显示 OSPF 简洁信息

OSPF Process 1 with Router ID 10.0.12.1

Peer Statistic Information

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

Area Id Interface Neighbor id State

0.0.0.0 Serial1/0/0 10.0.2.2 Full

0.0.0.0 GigabitEthernet0/0/0 10.0.3.3 Full

四、 修改 OSPF Hello 和 Dead 时间

display ospf interface g0/0/0 ====查看 OSPF Hello 与 Dead 默认时间

OSPF Process 1 with Router ID 10.0.12.1

Interfaces

Interface: 10.0.13.1 (GigabitEthernet0/0/0)

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

Priority: 1

Designated Router: 10.0.13.1

Backup Designated Router: 10.0.13.3

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

[R3]int g0/0/0

[R3-GigabitEthernet0/0/0]ospf timer hello 15

[R3-GigabitEthernet0/0/0]ospf timer dead 60

display ip routing-table protocol ospf

Route Flags: R - relay, D - download to fib

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

Public routing table : OSPF

Destinations : 1 Routes : 1

OSPF routing table status :

Destinations : 1 Routes : 1

Destination/Mask Proto Pre Cost Flags NextHop Interface

10.0.2.2/32 OSPF 10 48 D 10.0.12.2 Serial1/0/0

OSPF routing table status :

Destinations : 0 Routes : 0

注:由于 R1 和 R3 之间 hello 与 dead 时间不一致,所以邻居无法建立。

[R1]int g0/0/0

[R1-GigabitEthernet0/0/0]ospf timer hello 15

[R1-GigabitEthernet0/0/0]ospf timer dead 60

[R1]display ip routing-table protocol ospf

Route Flags: R - relay, D - download to fib

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

Public routing table : OSPF

Destinations : 2 Routes : 2

OSPF routing table status :

Destinations : 2 Routes : 2

Destination/Mask Proto Pre Cost Flags NextHop Interface

10.0.2.2/32 OSPF 10 48 D 10.0.12.2 Serial1/0/0

10.0.3.3/32 OSPF 10 1 D 10.0.13.3 GigabitEthernet0/0/0

OSPF routing table status :

Destinations : 0 Routes : 0

=================OSPF 邻居建立必要条件================

-id 不能相同

and dead 必须相同

3.区域 ID 必须相同

4.认证 key-id 及密码必须相同

5.特殊区域标记相同

6.三层 MTU 必须相同

7.子网掩码必须相同(在一个需要 DR|BDR 环境中)

8.最小范围内的双向互通

五、 OSPF 重分布默认路由

[R3]ip route-static 0.0.0.0 0 lo 1

[R3]ospf 100

[R3-ospf-100]default-route-advertise ====重分布默认路由

display ip routing-table protocol os | in 0.0.0.0

Route Flags: R - relay, D - download to fib

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

Public routing table : OSPF

Destinations : 3 Routes : 3

OSPF routing table status :

Destinations : 3 Routes : 3

Destination/Mask Proto Pre Cost Flags NextHop Interface

0.0.0.0/0 O_ASE 150 1 D 10.0.13.3 GigabitEthernet0/0/0

OSPF routing table status :

Destinations : 0 Routes : 0

ping 172.16.0.1

PING 172.16.0.1: 56 data bytes, press CTRL_C to break

Reply from 172.16.0.1: bytes=56 Sequence=1 ttl=255 time=10 ms

Reply from 172.16.0.1: bytes=56 Sequence=2 ttl=255 time=20 ms

Reply from 172.16.0.1: bytes=56 Sequence=3 ttl=255 time=10 ms

六、 OSPF DR/BDR 选举

display ospf peer

OSPF Process 1 with Router ID 10.0.12.1

Neighbors

Area 0.0.0.0 interface 10.0.12.1(Serial1/0/0)'s neighbors

Router ID: 10.0.2.2 Address: 10.0.12.2

State: Full Mode:Nbr is Slave Priority: 1

DR: None BDR: None MTU: 0

Dead timer due in 31 sec

Retrans timer interval: 5

Neighbor is up for 01:17:49

Authentication Sequence: [ 0 ]

Neighbors

Area 0.0.0.0 interface 10.0.13.1(GigabitEthernet0/0/0)'s neighbors

Router ID: 10.0.3.3 Address: 10.0.13.3

State: Full Mode:Nbr is Slave Priority: 1

DR: 10.0.13.1 BDR: 10.0.13.3 MTU: 0

Dead timer due in 59 sec

Retrans timer interval: 5

Neighbor is up for 00:30:15

Authentication Sequence: [ 0 ]

注:默认优先级是 1,由于 R3 router-id 大于 R1 router-id 所以 R3 为 DR,R1 为 BDR。

[R1]int g0/0/0

[R1-GigabitEthernet0/0/0]ospf dr-priority 200 ====配置 OSPF 优先级为 200

注:由于 DR/BDR 选举默认为不抢占模式,因此修改了优先级后,不会重新进行选举,所以要重置 R1 与 R3 之间邻居关系。

[R1]int g0/0/0

[R1-GigabitEthernet0/0/0]shut

[R1-GigabitEthernet0/0/0]undo shut

display ospf pee

OSPF Process 100 with Router ID 10.0.3.3

Neighbors

Area 0.0.0.0 interface 10.0.13.3(GigabitEthernet0/0/0)'s neighbors

Router ID: 10.0.12.1 Address: 10.0.13.1

State: Full Mode:Nbr is Master Priority: 200

DR: 10.0.13.1 BDR: 10.0.13.3 MTU: 0

Dead timer due in 52 sec

Retrans timer interval: 5

Neighbor is up for 00:02:10

Authentication Sequence: [ 0 ]

LAB2 拓扑如下

七、 配置 OSPF 多区域

R1:

[R1]ospf 1 router-id 10.0.1.1

[R1-ospf-1]area 0

[R1-ospf-1-area-0.0.0.0]network 10.0.12.0 0.0.0.255

[R1-ospf-1-area-0.0.0.0]quit

[R1-ospf-1]area 1

[R1-ospf-1-area-0.0.0.1]network 10.0.13.0 0.0.0.255

[R1-ospf-1-area-0.0.0.1]network 10.0.1.0 0.0.0.255

R2:

[R2]ospf 1 router-id 10.0.2.2

[R2-ospf-1]area 0

[R2-ospf-1-area-0.0.0.0]network 10.0.12.0 0.0.0.255

[R2-ospf-1-area-0.0.0.0]network 10.0.2.0 0.0.0.255

R3:

[R3]ospf 1 router-id 10.0.3.3

[R3-ospf-1]area 1

[R3-ospf-1-area-0.0.0.1]network 10.0.3.0 0.0.0.255

[R3-ospf-1-area-0.0.0.1]network 10.0.13.0 0.0.0.255

测试:

display ip rou pr os

Route Flags: R - relay, D - download to fib

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

Public routing table : OSPF

Destinations : 2 Routes : 2

OSPF routing table status :

Destinations : 2 Routes : 2

Destination/Mask Proto Pre Cost Flags NextHop Interface

10.0.2.2/32 OSPF 10 48 D 10.0.12.2 Serial1/0/0

10.0.3.3/32 OSPF 10 1 D 10.0.13.3 GigabitEthernet0/0/0

OSPF routing table status :

Destinations : 0 Routes : 0

display ip routing-table protocol ospf

Route Flags: R - relay, D - download to fib

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

Public routing table : OSPF

Destinations : 3 Routes : 3

OSPF routing table status :

Destinations : 3 Routes : 3

Destination/Mask Proto Pre Cost Flags NextHop Interface

10.0.1.1/32 OSPF 10 48 D 10.0.12.1 Serial1/0/0

10.0.3.3/32 OSPF 10 49 D 10.0.12.1 Serial1/0/0

10.0.13.0/24 OSPF 10 49 D 10.0.12.1 Serial1/0/0

OSPF routing table status :

Destinations : 0 Routes : 0

ping -c 2 10.0.3.3

PING 10.0.3.3: 56 data bytes, press CTRL_C to break

Reply from 10.0.3.3: bytes=56 Sequence=1 ttl=255 time=20 ms

Reply from 10.0.3.3: bytes=56 Sequence=2 ttl=255 time=20 ms

ping -c 2 10.0.2.2

PING 10.0.2.2: 56 data bytes, press CTRL_C to break

Reply from 10.0.2.2: bytes=56 Sequence=1 ttl=255 time=10 ms

Reply from 10.0.2.2: bytes=56 Sequence=2 ttl=255 time=10 ms

display ospf peer brief

OSPF Process 1 with Router ID 10.0.1.1

Peer Statistic Information

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

Area Id Interface Neighbor id State

0.0.0.0 Serial1/0/0 10.0.2.2 Full

0.0.0.1 GigabitEthernet0/0/0 10.0.3.3 Full

八、 OSPF 直连路由重分布

[R3]ospf 1

[R3-ospf-1]import-route direct ====重分布直连

测试:

dis ip rout protocol os

Route Flags: R - relay, D - download to fib

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

Public routing table : OSPF

Destinations : 4 Routes : 4

OSPF routing table status :

Destinations : 4 Routes : 4

Destination/Mask Proto Pre Cost Flags NextHop Interface

10.0.2.2/32 OSPF 10 48 D 10.0.12.2 Serial1/0/0

10.0.3.0/24 O_ASE 150 1 D 10.0.13.3 GigabitEthernet0/0/0

10.0.3.3/32 OSPF 10 1 D 10.0.13.3 GigabitEthernet0/0/0

172.16.0.0/24 O_ASE 150 1 D 10.0.13.3 GigabitEthernet0/0/0

注:O_ASE 表示 OSPF 外部路由

ping -a 10.0.2.2 10.0.3.3 ====以 IP 10.0.2.2 为源

PING 10.0.3.3: 56 data bytes, press CTRL_C to break

Reply from 10.0.3.3: bytes=56 Sequence=1 ttl=254 time=20 ms

Reply from 10.0.3.3: bytes=56 Sequence=2 ttl=254 time=10 ms

Reply from 10.0.3.3: bytes=56 Sequence=3 ttl=254 time=20 ms

Reply from 10.0.3.3: bytes=56 Sequence=4 ttl=254 time=20 ms

R1>display ospf lsdb ==== 查看 LSA 数据库

OSPF Process 1 with Router ID 10.0.1.1

Link State Database

Area: 0.0.0.0

Type LinkState ID AdvRouter Age Len Sequence Metric

Router 10.0.2.2 10.0.2.2 1536 60 80000003 48

Router 10.0.1.1 10.0.1.1 1558 48 80000003 48

Sum-Net 10.0.13.0 10.0.1.1 1773 28 80000001 1

Sum-Net 10.0.3.3 10.0.1.1 1407 28 80000001 1

Sum-Net 10.0.1.1 10.0.1.1 1766 28 80000001 0

Sum-Asbr 10.0.3.3 10.0.1.1 522 28 80000001 1

Area: 0.0.0.1

Type LinkState ID AdvRouter Age Len Sequence Metric

Router 10.0.3.3 10.0.3.3 523 48 80000005 1

Router 10.0.1.1 10.0.1.1 1399 48 80000006 1

Network 10.0.13.1 10.0.1.1 1399 32 80000002 0

Sum-Net 10.0.12.0 10.0.1.1 1773 28 80000001 48

Sum-Net 10.0.2.2 10.0.1.1 1535 28 80000001 48

AS External Database

Type LinkState ID AdvRouter Age Len Sequence Metric

External 10.0.3.0 10.0.3.3 523 36 80000001 1

External 10.0.13.0 10.0.3.3 523 36 80000001 1

External 172.16.0.0 10.0.3.3 523 36 80000001 1

display ospf lsdb summary 10.0.3.3 =====查看 TYPE 3 LSA

OSPF Process 1 with Router ID 10.0.1.1

Area: 0.0.0.0

Link State Database

Type : Sum-Net

Ls id : 10.0.3.3

Adv rtr : 10.0.1.1

Ls age : 1693

Len : 28

Options : E

seq# : 80000001

chksum : 0x4cf3

Net mask : 255.255.255.255

Tos 0 metric: 1

Priority : Low

Area: 0.0.0.1

Link State Database

display ospf lsdb asbr ====查看 TYPE 4 LSA

OSPF Process 1 with Router ID 10.0.1.1

Area: 0.0.0.0

Link State Database

Type : Sum-Asbr

Ls id : 10.0.3.3

Adv rtr : 10.0.1.1

Ls age : 1031

Len : 28

Options : E

seq# : 80000001

chksum : 0x3e01

Tos 0 metric: 1

Area: 0.0.0.1

Link State Database

display ospf lsdb ase 172.16.0.0 ====查看 TYPE 5 LSA

OSPF Process 1 with Router ID 10.0.1.1

Link State Database

Type : External

Ls id : 172.16.0.0

Adv rtr : 10.0.3.3

Ls age : 1109

Len : 36

Options : E

seq# : 80000001

chksum : 0xf70c

Net mask : 255.255.255.0

TOS 0 Metric: 1

E type : 2

Forwarding Address : 0.0.0.0

Tag : 1

Priority : Low

九、 配置 OSPF 认证

[R1]int s1/0/0

[R1-Serial1/0/0]ospf authentication-mode simple plain password

[R2]int s1/0/0

[R2-Serial1/0/0]ospf authentication-mode simple plain password

[R1-ospf-1]area 1

[R1-ospf-1-area-0.0.0.1]authentication-mode md5 1 cipher password

[R2-ospf-1]area 1

[R2-ospf-1-area-0.0.0.1]authentication-mode md5 1 cipher password


本文标签: 区域 邻居 默认 路由