祖瑞科技 全国计算机 网络IT运维社区!

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 活动 交友 discuz
查看: 5172|回复: 0

HCNA-34 OSPF的DR与BDR

[复制链接]

199

主题

212

帖子

1200

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1200
发表于 2021-2-5 17:21:39 | 显示全部楼层 |阅读模式
HCNA-34 OSPF的DR与BDR

标注:DR/Designated Router 指定路由;BDR/BackupDesignated Router 备份指定路由;NBMA/Non-Broadcast MultipleAccess 非广播多路访问;邻接关系公式n*(n-1)/2;
OSPF链路分为3种:1、广播(broadcast)2、NBMA 3、点到点(point-to-point)再扩展出5种类型:1、广播 2、NBMA 3、点到点4、点到多点(point-to-multipoint) 5、虚链路
<Huawei>system-view
[Huawei]sysnamer1
[r1]interfaceloopback 0  //创建环回口 0
[r1-LoopBack0]ipaddress 1.1.1.1 32
[r1-LoopBack0]interfaceGigabitEthernet 0/0/0
[r1-GigabitEthernet0/0/0]ipaddress 172.16.100.1 24
[r1-GigabitEthernet0/0/0]
[r1-GigabitEthernet0/0/0]quit
[r1]routerid 1.1.1.1  //配置全局路由ID
[r1]ospf1  //创建OSPF 进程1
[r1-ospf-1]area0  //创建骨干区域 0
[r1-ospf-1-area-0.0.0.0]network1.1.1.1 0.0.0.0  //通告参考网络 地址段+通配符掩码
[r1-ospf-1-area-0.0.0.0]network172.16.100.0 0.0.0.255
[r1-ospf-1-area-0.0.0.0]authentication-modemd5 1 cipher admin1234  //配置身份认证模式为MD5 密文加加密
[r1-ospf-1-area-0.0.0.0]return
<Huawei>system-view
[Huawei]sysnamer2
[r2]interfaceloopback 0
[r2-LoopBack0]ipaddress 2.2.2.2 32
[r2-LoopBack0]interfaceGigabitEthernet 0/0/0
[r2-GigabitEthernet0/0/0]ipaddress 172.16.100.2 24
[r2-GigabitEthernet0/0/0]quit
[r2]routerid 2.2.2.2
[r2]ospf1
[r2-ospf-1]area0
[r2-ospf-1-area-0.0.0.0]network2.2.2.2 0.0.0.0
[r2-ospf-1-area-0.0.0.0]network172.16.100.0 0.0.0.255
[r2-ospf-1-area-0.0.0.0]authentication-modemd5 1 cipher admin1234
[r2-ospf-1-area-0.0.0.0]return
<Huawei>system-view
[Huawei]sysnamer3
[r3]interfaceloopback 0
[r3-LoopBack0]ipaddress 3.3.3.3 32
[r3-LoopBack0]interfaceGigabitEthernet 0/0/0
[r3-GigabitEthernet0/0/0]ipaddress 172.16.100.3 24
[r3-GigabitEthernet0/0/0]quit
[r3]routerid 3.3.3.3
[r3]ospf1
[r3-ospf-1]area0
[r3-ospf-1-area-0.0.0.0]network3.3.3.3 0.0.0.0
[r3-ospf-1-area-0.0.0.0]network172.16.100.0 0.0.0.255
[r3-ospf-1-area-0.0.0.0]authentication-modemd5 1 cipher admin1234
[r3-ospf-1-area-0.0.0.0]
[r3-ospf-1-area-0.0.0.0]return
<Huawei>system-view
[Huawei]sysnamer4
[r4]interfaceloopback 0
[r4-LoopBack0]ipaddress 4.4.4.4 32
[r4-LoopBack0]interfaceGigabitEthernet 0/0/0
[r4-GigabitEthernet0/0/0]ipaddress 172.16.100.4 24
[r4-GigabitEthernet0/0/0]quit
[r4]routerid 4.4.4.4
[r4]ospf1
[r4-ospf-1]area0
[r4-ospf-1-area-0.0.0.0]network4.4.4.4 0.0.0.0
[r4-ospf-1-area-0.0.0.0]network172.16.100.0 0.0.0.255
[r4-ospf-1-area-0.0.0.0]authentication-modemd5 1 cipher admin1234
[r4-ospf-1-area-0.0.0.0]return
配置完成后,同步重启四台路由,让OSPF重新进行计算,选举出DR,BDR
<r1>displayospf peer brief  //查看OSPF邻居简要信息
        OSPF Process 1 with Router ID 1.1.1.1
               Peer Statistic Information  
----------------------------------------------------------------------------
Area Id          Interface                        Neighbor id      State   
0.0.0.0          GigabitEthernet0/0/0             2.2.2.2          Full        
0.0.0.0          GigabitEthernet0/0/0             3.3.3.3          Full        
0.0.0.0          GigabitEthernet0/0/0             4.4.4.4          Full      
----------------------------------------------------------------------------
4组路由器已经成功建立起邻居关系。
下面验证一下默认情况下DR和BDR状态
<r1>displayospf peer  //查看OSPF邻居状态
        OSPF Process 1 with Router ID 1.1.1.1
               Neighbors
Area 0.0.0.0 interface172.16.100.1(GigabitEthernet0/0/0)'s neighbors
Router ID: 2.2.2.2          Address: 172.16.100.2   
   State: Full Mode:Nbr is  Master  Priority: 1
   DR: 172.16.100.3  BDR:172.16.100.2  MTU: 0   
   Dead timer due in 33  sec
   Retrans timer interval: 4
   Neighbor is up for 00:17:06     
   Authentication Sequence: [ 76]
Router ID: 3.3.3.3          Address: 172.16.100.3   
   State: Full Mode:Nbr is  Master  Priority: 1
   DR: 172.16.100.3  BDR:172.16.100.2  MTU: 0   
   Dead timer due in 34  sec
   Retrans timer interval: 5
   Neighbor is up for 00:17:04     
   Authentication Sequence: [ 80]
Router ID: 4.4.4.4          Address: 172.16.100.4   
   State: 2-Way Mode:Nbr is  Master  Priority: 1
   DR: 172.16.100.3  BDR:172.16.100.2  MTU: 0   
   Dead timer due in 37  sec
   Retrans timer interval: 0
   Neighbor is up for 00:00:00     
   Authentication Sequence: [ 0 ]
分析得出:R3是DR,R2是BDR;在默认情况下每台路由器上的DR优先级都是1,此时是通过Router-ID的数值高低来进行比较的,数值大的会成为DR,次之百为BDR;那么在目前这个情况,为何DR是R3,BDR是R2,这个是根据路由器的配置或启动序列排列的,可以认为谁先配置谁成为DR,谁先启动,谁成为DR。
下面配置每台设备上的相关接口下使用ospf network-type p2mp命令修改OSPF的网络类型为点到多点。
[r1]interfaceGigabitEthernet 0/0/0
[r1-GigabitEthernet0/0/0]ospfnetwork-type p2mp
[r2]interfaceGigabitEthernet 0/0/0
[r2-GigabitEthernet0/0/0]ospfnetwork-type p2mp
[r3]interfaceGigabitEthernet 0/0/0
[r3-GigabitEthernet0/0/0]ospfnetwork-type p2mp
[r4]interfaceGigabitEthernet 0/0/0
[r4-GigabitEthernet0/0/0]ospfnetwork-type p2mp
[r1]displayospf peer
        OSPF Process 1 with Router ID 1.1.1.1
               Neighbors
Area 0.0.0.0 interface172.16.100.1(GigabitEthernet0/0/0)'s neighbors
Router ID: 2.2.2.2          Address: 172.16.100.2   
   State: Full Mode:Nbr is  Master  Priority: 1
   DR: None   BDR: None   MTU: 0   
   Dead timer due in 93  sec
   Retrans timer interval: 5
   Neighbor is up for 00:04:12     
   Authentication Sequence: [ 585]
Router ID: 3.3.3.3          Address: 172.16.100.3   
   State: Full Mode:Nbr is  Master  Priority: 1
   DR: None   BDR: None   MTU: 0   
   Dead timer due in 113 sec
   Retrans timer interval: 5
   Neighbor is up for 00:03:44     
   Authentication Sequence: [ 580]
Router ID: 4.4.4.4          Address: 172.16.100.4   
   State: Full Mode:Nbr is  Master  Priority: 1
   DR: None   BDR: None   MTU: 0   
   Dead timer due in 90  sec
   Retrans timer interval: 5
   Neighbor is up for 00:02:46     
   Authentication Sequence: [ 576]
分析得出,DR和BDR全部为None,说明了一点,在OSPF点多到点和点到点网络中,不存在DR与BDR的选举。
下面根据拓扑要求配置影响DR/BDR选举:
R1为DR(性能最好);R2为BDR(性能次之);R4不参选(因为性能最差);R3成为DR Other
[r1]interfaceGigabitEthernet 0/0/0
[r1-GigabitEthernet0/0/0]ospfnetwork-type broadcast  //配置OSPF网络类型为广播网络
[r2]interfaceGigabitEthernet 0/0/0
[r2-GigabitEthernet0/0/0]ospfnetwork-type broadcast
[r3]interfaceGigabitEthernet 0/0/0
[r3-GigabitEthernet0/0/0]ospfnetwork-type broadcast
[r4]interfaceGigabitEthernet 0/0/0
[r4-GigabitEthernet0/0/0]ospfnetwork-type broadcast
[r1]interfaceGigabitEthernet 0/0/0
[r1-GigabitEthernet0/0/0]ospfdr-priority 100  //配置OSPF DR优先级为100
[r2]interfaceGigabitEthernet 0/0/0
[r2-GigabitEthernet0/0/0]ospfdr-priority 50
[r4]interfaceGigabitEthernet 0/0/0
[r4-GigabitEthernet0/0/0]ospfdr-priority 0
验证DR/BDR
<r1>displayospf peer
        OSPF Process 1 with Router ID 1.1.1.1
               Neighbors
Area 0.0.0.0 interface172.16.100.1(GigabitEthernet0/0/0)'s neighbors
Router ID: 2.2.2.2          Address: 172.16.100.2   
   State: Full Mode:Nbr is  Master  Priority: 50
   DR: 172.16.100.1  BDR:172.16.100.2  MTU: 0   
   Dead timer due in 39  sec
   Retrans timer interval: 5
   Neighbor is up for 00:17:00     
   Authentication Sequence: [ 2095]
Router ID: 3.3.3.3          Address: 172.16.100.3   
   State: Full Mode:Nbr is  Master  Priority: 1
   DR: 172.16.100.1  BDR:172.16.100.2  MTU: 0   
   Dead timer due in 31  sec
   Retrans timer interval: 5
   Neighbor is up for 00:14:48     
   Authentication Sequence: [ 2090]
Router ID: 4.4.4.4          Address: 172.16.100.4   
   State: Full Mode:Nbr is  Master  Priority: 0
   DR: 172.16.100.1  BDR:172.16.100.2  MTU: 0   
   Dead timer due in 37  sec
   Retrans timer interval: 5
   Neighbor is up for 00:01:41     
   Authentication Sequence: [ 2087]
此时网络实现了拓扑要求。
说明:ospf dr-priority 优先级越高,越会成为DR,次之成为BDR,优先级为0则代表不参与选举。
<r3>displayospf brief
        OSPF Process 1 with Router ID 3.3.3.3
               OSPF Protocol Information
RouterID: 3.3.3.3          Border Router:
……
Area: 0.0.0.0          (MPLS TE not enabled)
Authtype: MD5  Area flag: Normal
SPF scheduled Count: 53   
ExChange/Loading Neighbors: 0
Router ID conflict state: Normal
Area interface up count: 2
Interface: 172.16.100.3 (GigabitEthernet0/0/0)
Cost: 1      State: DROther    Type: Broadcast    MTU: 1500
Priority: 1
Designated Router: 172.16.100.1
Backup Designated Router: 172.16.100.2
Timers: Hello 10 , Dead 40 , Poll  120 , Retransmit 5 , Transmit Delay 1
Interface: 3.3.3.3 (LoopBack0)
Cost: 0      State: P-2-P     Type: P2P       MTU: 1500  
Timers: Hello 10 , Dead 40 , Poll  120 , Retransmit 5 , Transmit Delay 1
R3也自然成为了DR Other。
测试网络:
<r1>ping-a 1.1.1.1 2.2.2.2
  PING 2.2.2.2: 56  data bytes, press CTRL_C to break
    Reply from 2.2.2.2: bytes=56 Sequence=1ttl=255 time=170 ms
    Reply from 2.2.2.2: bytes=56 Sequence=2ttl=255 time=40 ms
    Reply from 2.2.2.2: bytes=56 Sequence=3ttl=255 time=40 ms
    Reply from 2.2.2.2: bytes=56 Sequence=4ttl=255 time=50 ms
    Replyfrom 2.2.2.2: bytes=56 Sequence=5 ttl=255 time=50 ms
  --- 2.2.2.2 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 40/70/170 ms
<r1>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=1ttl=255 time=70 ms
    Reply from 3.3.3.3: bytes=56 Sequence=2ttl=255 time=40 ms
    Reply from 3.3.3.3: bytes=56 Sequence=3ttl=255 time=40 ms
    Reply from 3.3.3.3: bytes=56 Sequence=4ttl=255 time=40 ms
    Reply from 3.3.3.3: bytes=56 Sequence=5ttl=255 time=50 ms
  --- 3.3.3.3 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 40/48/70 ms
<r1>ping-a 1.1.1.1 4.4.4.4
  PING 4.4.4.4: 56  data bytes, press CTRL_C to break
    Reply from 4.4.4.4: bytes=56 Sequence=1ttl=255 time=100 ms
    Reply from 4.4.4.4: bytes=56 Sequence=2ttl=255 time=50 ms
    Reply from 4.4.4.4: bytes=56 Sequence=3ttl=255 time=50 ms
    Reply from 4.4.4.4: bytes=56 Sequence=4ttl=255 time=50 ms
    Reply from 4.4.4.4: bytes=56 Sequence=5ttl=255 time=50 ms
  --- 4.4.4.4 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 50/60/100 ms

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
祖瑞(上海)网络科技有限公司
我们在全国范围提供企业IT运维、网络工程、弱电安装、监控安防、计算机产品收售、办公设备耗材等服务!
期待与您的合作!
邮箱:sanne@zurkj.com
电话:021-51850021 18918292296
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

公司网站

QQ|Archiver|手机版|小黑屋|祖瑞科技 全国计算机 网络IT运维社区! ( 沪ICP备16021636号-2 )

GMT+8, 2024-5-4 02:35 , Processed in 0.055207 second(s), 19 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表