メインコンテンツへスキップ
  1. ネットワーク 記事一覧/
  2. OSPF記事一覧/

DRとBDR

目次

DRとBDRとは

イーサネットのように1本のセグメントに3台以上のルータがつながるネットワーク(マルチアクセスネットワーク)では、そのままでは全部のルータ同士が隣接関係(アジャセンシー)を結ぼうとします。台数を n とすると隣接関係は n × (n − 1) ÷ 2 本になり、台数が増えるほど急激に増えていきます。

隣接関係の数だけLSDBの同期とLSAの再送管理が必要になるため、これはルータの負荷とセグメント上のトラフィックの両方で無駄になります。そこでOSPFは、セグメントごとに代表となるルータを1台選び、そのルータを経由してLSAをやり取りします。この代表がDR(Designated Router、指名ルータ)です。DRが落ちたときにすぐ引き継げるよう、控えのBDR(Backup Designated Router、バックアップ指名ルータ)も同時に選出します。DRにもBDRにもならなかったルータはDROTHERと呼ばれます。

DROTHER同士は隣接関係を結ばず、2-Wayのままで止まります。隣接関係はDRとBDRを中心とした星形になり、本数は n × (n − 1) ÷ 2 から 2 × n − 3 に減ります。

セグメント上の台数DR/BDRなしDR/BDRあり
3台3本3本
5台10本7本
10台45本17本
20台190本37本

3台では変わりませんが、台数が増えるほど差が大きくなります。

DR・BDR・DROTHERの役割

役割隣接関係を結ぶ相手LSAの扱い
DRセグメント上のすべてのルータ各ルータから受け取ったLSAをセグメント全体へ中継する。セグメントを表すNetwork-LSA(Type 2)を生成する。
BDRセグメント上のすべてのルータDRと同じようにLSAを受け取るが、中継はしない。DRがダウンしたら昇格して中継を引き継ぐ。
DROTHERDRとBDRのみLSAはDRとBDRにだけ送る。DROTHER同士は2-Wayのまま。

この動きは、送信先のマルチキャストアドレスの使い分けとして現れます。

DROTHERがLSAを送るときは、DRとBDRだけが受信する224.0.0.6を使います。

受け取ったDRは、そのLSAをセグメント上の全ルータが受信する224.0.0.5で配り直します。

アドレス名前受信するルータこのアドレス宛に送るルータ
224.0.0.5AllSPFRoutersすべてのOSPFルータすべてのルータ(Hello)と、DR・BDR(LSAを送るとき)
224.0.0.6AllDRoutersDRとBDRだけDROTHER(LSAを送るとき)

Helloは役割に関係なく全ルータが224.0.0.5宛に送ります。224.0.0.6を使うのは、DROTHERがLSU・LSAckを送るときだけです。BDRもLSAを送るときは224.0.0.5を使いますが、他のルータのLSAを中継することはありません。

DRが生成するNetwork-LSA(Type 2)については、別記事で解説します。

DR/BDRの選出

DR/BDRの選出は、Helloパケットに載っているプライオリティルータIDで決まります。

  1. プライオリティが最も高いルータがDRになる
  2. 次に高いルータがBDRになる
  3. プライオリティが同じ場合は、ルータIDが大きいルータが優先される

プライオリティの既定値は1で、0を設定したルータはDRにもBDRにもなりません(常にDROTHER)。

選出は非プリエンプティブ

一度DR/BDRが決まると、あとからプライオリティの高いルータが参加してもDRは交代しません。DRが交代するのは、現在のDRがダウンしたときだけです。そのときはBDRが昇格してDRになり、残りのルータから新しいBDRが選出されます。

この動きは、DRの交代がセグメント全体のLSDBの再同期を伴う重い処理だからです。プライオリティの高いルータが入るたびに交代していては、ネットワークが安定しません。

Waitタイマー

インタフェースでOSPFが有効になった直後、ルータはすぐには選出を始めず、Waitタイマー(既定値はDeadインターバルと同じ40秒)の間、他のルータのHelloを聞きます。この間の状態はshow ospf interfaceState WAITINGと表示されます。全台がほぼ同時に起動した場合は、この待ち時間の中で互いのプライオリティを知ってから選出が行われます。

一方、すでにDRが決まっているセグメントに後から参加したルータは、受け取ったHelloに載っているDR/BDRをそのまま受け入れます。

実機での検証

検証環境

Cisco IOS XR(XRd 26.1.1)のルータ4台を1つのイーサネットセグメント(10.0.0.0/24)に接続し、プライオリティを変えて選出結果を確認します。

ルータルータIDプライオリティ想定される役割
R11.1.1.1100DR
R22.2.2.250BDR
R33.3.3.30DROTHER(対象外)
R44.4.4.41(既定値)DROTHER

R4はルータIDが最も大きいのにDROTHERになる想定です。プライオリティがルータIDより優先されることを確認するためです。

検証はプライオリティの変更やインタフェースのshutdownを挟みながら7段階(STEP 0〜6)で進めます。各STEPで4台すべてから取得したshow出力・syslog・running-configは、記事末尾の検証Configおよびshow結果にSTEPごとにまとめました。以降の節で引用しているのは、そのうちの一部です。

STEP操作結果(DR / BDR)
04台を起動しただけの初期状態R1 / R2
1R4のプライオリティを255に変更R1 / R2(変わらない)
24台のOSPFプロセスを一斉に再起動R4 / R1
3R4のプライオリティを既定値に戻して一斉に再起動R1 / R2
4R1のGi0/0/0/0をshutdownR2 / R4
5R1のGi0/0/0/0をno shutdownR2 / R4(R1はDROTHER)
64台のOSPFプロセスを一斉に再起動R1 / R2(初期状態へ復旧)

選出結果(STEP 0)

4台を起動すると、プライオリティどおりR1がDR、R2がBDRになりました。同じセグメントを4台がそれぞれどう見ているかを、タブで切り替えて比べられます。

STEP 0 R1 show ospf interface / show ospf neighbor
RP/0/RP0/CPU0:R1#show ospf interface
Sat Sep  5 14:03:16.746 UTC

Interfaces for OSPF 1

Loopback0 is up, line protocol is up 
  Internet Address 1.1.1.1/32, Area 0, SID 0, Strict-SPF SID 0
  Label stack Primary label 0 Backup label 0 SRTE label 0
  Process ID 1, Router ID 1.1.1.1, Network Type LOOPBACK, Cost: 1
  Loopback interface is treated as a stub Host
  Multi-area interface Count is 0
GigabitEthernet0/0/0/0 is up, line protocol is up 
  Internet Address 10.0.0.1/24, Area 0, SID 0, Strict-SPF SID 0
  Label stack Primary label 0 Backup label 0 SRTE label 0
  Process ID 1, Router ID 1.1.1.1, Network Type BROADCAST, Cost: 1
  Transmit Delay is 1 sec, State DR, Priority 100, MTU 1500, MaxPktSz 1500
  Forward reference No, Unnumbered no,  Bandwidth 1000000 
  RIB LC sync Yes
  Designated Router (ID) 1.1.1.1, Interface address 10.0.0.1
  Backup Designated router (ID) 2.2.2.2, Interface address 10.0.0.2
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    Hello due in 00:00:09:514
  Index 1/1, flood queue length 0
  Next 0(0)/0(0)
  Last flood scan length is 1, maximum is 1
  Last flood scan time is 0 msec, maximum is 0 msec
  LS Ack List: current length 0, high water mark 1
  Neighbor Count is 3, Adjacent neighbor count is 3
    Adjacent with neighbor 2.2.2.2  (Backup Designated Router)
    Adjacent with neighbor 3.3.3.3
    Adjacent with neighbor 4.4.4.4
  Suppress hello for 0 neighbor(s)
  Multi-area interface Count is 0
  Segment Routing Forwarding MPLS enabled: Yes
  Adjacency hold timer expired last : Never
  Exchange timer expired last : Never

RP/0/RP0/CPU0:R1#show ospf neighbor
Sat Sep  5 14:03:18.071 UTC

* Indicates MADJ interface
# Indicates Neighbor awaiting BFD session up

Neighbors for OSPF 1

Neighbor ID     Pri   State           Dead Time   Address         Interface
2.2.2.2         50    FULL/BDR        00:00:34    10.0.0.2        GigabitEthernet0/0/0/0
    Neighbor is up for 00:01:59
3.3.3.3         0     FULL/DROTHER    00:00:31    10.0.0.3        GigabitEthernet0/0/0/0
    Neighbor is up for 00:01:53
4.4.4.4         1     FULL/DROTHER    00:00:32    10.0.0.4        GigabitEthernet0/0/0/0
    Neighbor is up for 00:01:43

Total neighbor count: 3
STEP 0 R2 show ospf interface / show ospf neighbor
RP/0/RP0/CPU0:R2#show ospf interface
Sat Sep  5 14:03:36.667 UTC

Interfaces for OSPF 1

Loopback0 is up, line protocol is up 
  Internet Address 2.2.2.2/32, Area 0, SID 0, Strict-SPF SID 0
  Label stack Primary label 0 Backup label 0 SRTE label 0
  Process ID 1, Router ID 2.2.2.2, Network Type LOOPBACK, Cost: 1
  Loopback interface is treated as a stub Host
  Multi-area interface Count is 0
GigabitEthernet0/0/0/0 is up, line protocol is up 
  Internet Address 10.0.0.2/24, Area 0, SID 0, Strict-SPF SID 0
  Label stack Primary label 0 Backup label 0 SRTE label 0
  Process ID 1, Router ID 2.2.2.2, Network Type BROADCAST, Cost: 1
  Transmit Delay is 1 sec, State BDR, Priority 50, MTU 1500, MaxPktSz 1500
  Forward reference No, Unnumbered no,  Bandwidth 1000000 
  RIB LC sync Yes
  Designated Router (ID) 1.1.1.1, Interface address 10.0.0.1
  Backup Designated router (ID) 2.2.2.2, Interface address 10.0.0.2
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    Hello due in 00:00:04:016
  Index 1/1, flood queue length 0
  Next 0(0)/0(0)
  Last flood scan length is 0, maximum is 1
  Last flood scan time is 0 msec, maximum is 0 msec
  LS Ack List: current length 0, high water mark 3
  Neighbor Count is 3, Adjacent neighbor count is 3
    Adjacent with neighbor 1.1.1.1  (Designated Router)
    Adjacent with neighbor 3.3.3.3
    Adjacent with neighbor 4.4.4.4
  Suppress hello for 0 neighbor(s)
  Multi-area interface Count is 0
  Segment Routing Forwarding MPLS enabled: Yes
  Adjacency hold timer expired last : Never
  Exchange timer expired last : Never

RP/0/RP0/CPU0:R2#show ospf neighbor
Sat Sep  5 14:03:37.996 UTC

* Indicates MADJ interface
# Indicates Neighbor awaiting BFD session up

Neighbors for OSPF 1

Neighbor ID     Pri   State           Dead Time   Address         Interface
1.1.1.1         100   FULL/DR         00:00:37    10.0.0.1        GigabitEthernet0/0/0/0
    Neighbor is up for 00:02:24
3.3.3.3         0     FULL/DROTHER    00:00:31    10.0.0.3        GigabitEthernet0/0/0/0
    Neighbor is up for 00:02:12
4.4.4.4         1     FULL/DROTHER    00:00:31    10.0.0.4        GigabitEthernet0/0/0/0
    Neighbor is up for 00:02:03

Total neighbor count: 3
STEP 0 R3 show ospf interface / show ospf neighbor
RP/0/RP0/CPU0:R3#show ospf interface
Sat Sep  5 14:03:55.806 UTC

Interfaces for OSPF 1

Loopback0 is up, line protocol is up 
  Internet Address 3.3.3.3/32, Area 0, SID 0, Strict-SPF SID 0
  Label stack Primary label 0 Backup label 0 SRTE label 0
  Process ID 1, Router ID 3.3.3.3, Network Type LOOPBACK, Cost: 1
  Loopback interface is treated as a stub Host
  Multi-area interface Count is 0
GigabitEthernet0/0/0/0 is up, line protocol is up 
  Internet Address 10.0.0.3/24, Area 0, SID 0, Strict-SPF SID 0
  Label stack Primary label 0 Backup label 0 SRTE label 0
  Process ID 1, Router ID 3.3.3.3, Network Type BROADCAST, Cost: 1
  Transmit Delay is 1 sec, State DROTHER, Priority 0, MTU 1500, MaxPktSz 1500
  Forward reference No, Unnumbered no,  Bandwidth 1000000 
  RIB LC sync Yes
  Designated Router (ID) 1.1.1.1, Interface address 10.0.0.1
  Backup Designated router (ID) 2.2.2.2, Interface address 10.0.0.2
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    Hello due in 00:00:01:667
  Index 1/1, flood queue length 0
  Next 0(0)/0(0)
  Last flood scan length is 0, maximum is 3
  Last flood scan time is 0 msec, maximum is 0 msec
  LS Ack List: current length 0, high water mark 4
  Neighbor Count is 3, Adjacent neighbor count is 2
    Adjacent with neighbor 1.1.1.1  (Designated Router)
    Adjacent with neighbor 2.2.2.2  (Backup Designated Router)
  Suppress hello for 0 neighbor(s)
  Multi-area interface Count is 0
  Segment Routing Forwarding MPLS enabled: Yes
  Adjacency hold timer expired last : Never
  Exchange timer expired last : Never

RP/0/RP0/CPU0:R3#show ospf neighbor
Sat Sep  5 14:03:57.362 UTC

* Indicates MADJ interface
# Indicates Neighbor awaiting BFD session up

Neighbors for OSPF 1

Neighbor ID     Pri   State           Dead Time   Address         Interface
1.1.1.1         100   FULL/DR         00:00:37    10.0.0.1        GigabitEthernet0/0/0/0
    Neighbor is up for 00:02:34
2.2.2.2         50    FULL/BDR        00:00:32    10.0.0.2        GigabitEthernet0/0/0/0
    Neighbor is up for 00:02:38
4.4.4.4         1     2WAY/DROTHER    00:00:31    10.0.0.4        GigabitEthernet0/0/0/0
    Neighbor is up for 00:02:22

Total neighbor count: 3
STEP 0 R4 show ospf interface / show ospf neighbor
RP/0/RP0/CPU0:R4#show ospf interface
Sat Sep  5 14:04:15.082 UTC

Interfaces for OSPF 1

Loopback0 is up, line protocol is up 
  Internet Address 4.4.4.4/32, Area 0, SID 0, Strict-SPF SID 0
  Label stack Primary label 0 Backup label 0 SRTE label 0
  Process ID 1, Router ID 4.4.4.4, Network Type LOOPBACK, Cost: 1
  Loopback interface is treated as a stub Host
  Multi-area interface Count is 0
GigabitEthernet0/0/0/0 is up, line protocol is up 
  Internet Address 10.0.0.4/24, Area 0, SID 0, Strict-SPF SID 0
  Label stack Primary label 0 Backup label 0 SRTE label 0
  Process ID 1, Router ID 4.4.4.4, Network Type BROADCAST, Cost: 1
  Transmit Delay is 1 sec, State DROTHER, Priority 1, MTU 1500, MaxPktSz 1500
  Forward reference No, Unnumbered no,  Bandwidth 1000000 
  RIB LC sync Yes
  Designated Router (ID) 1.1.1.1, Interface address 10.0.0.1
  Backup Designated router (ID) 2.2.2.2, Interface address 10.0.0.2
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    Hello due in 00:00:02:933
  Index 1/1, flood queue length 0
  Next 0(0)/0(0)
  Last flood scan length is 0, maximum is 1
  Last flood scan time is 0 msec, maximum is 0 msec
  LS Ack List: current length 0, high water mark 4
  Neighbor Count is 3, Adjacent neighbor count is 2
    Adjacent with neighbor 1.1.1.1  (Designated Router)
    Adjacent with neighbor 2.2.2.2  (Backup Designated Router)
  Suppress hello for 0 neighbor(s)
  Multi-area interface Count is 0
  Segment Routing Forwarding MPLS enabled: Yes
  Adjacency hold timer expired last : Never
  Exchange timer expired last : Never

RP/0/RP0/CPU0:R4#show ospf neighbor
Sat Sep  5 14:04:16.748 UTC

* Indicates MADJ interface
# Indicates Neighbor awaiting BFD session up

Neighbors for OSPF 1

Neighbor ID     Pri   State           Dead Time   Address         Interface
1.1.1.1         100   FULL/DR         00:00:37    10.0.0.1        GigabitEthernet0/0/0/0
    Neighbor is up for 00:02:44
2.2.2.2         50    FULL/BDR        00:00:32    10.0.0.2        GigabitEthernet0/0/0/0
    Neighbor is up for 00:02:48
3.3.3.3         0     2WAY/DROTHER    00:00:39    10.0.0.3        GigabitEthernet0/0/0/0
    Neighbor is up for 00:02:42

Total neighbor count: 3

R1(DR)とR2(BDR)はAdjacent neighbor count is 3で、セグメント上の全員と隣接関係を結んでいます。R3とR4(DROTHER)はNeighbor Count is 3, Adjacent neighbor count is 2で、ネイバーは3台見えているのに隣接関係はDRとBDRの2台とだけです。

DROTHERのshow ospf interfaceにはDesignated Router (ID)の行がありません。DR/BDR以外は自分がその役割ではないため表示されない、というだけで異常ではありません。

ルータプライオリティルータID結果
R11001.1.1.1DR
R2502.2.2.2BDR
R303.3.3.3DROTHER(プライオリティ0のため対象外)
R414.4.4.4DROTHER

R4はルータIDが4.4.4.4で4台の中では最大ですが、プライオリティが既定値の1しかないためDROTHERです。プライオリティがルータIDより優先されることがそのまま出ています。

DROTHER同士は2-Wayで止まる(STEP 0)

上のタブでR3とR4を見比べると、show ospf neighborState欄が次のようになっています。

見ている側R1(DR)R2(BDR)R3R4
R1FULL/BDRFULL/DROTHERFULL/DROTHER
R2FULL/DRFULL/DROTHERFULL/DROTHER
R3FULL/DRFULL/BDR2WAY/DROTHER
R4FULL/DRFULL/BDR2WAY/DROTHER

State欄は「自分から見たネイバーの状態 / そのネイバーの役割」という書式です。DROTHERのR3とR4は、互いを2WAYのままにしています。これは異常ではなく、DROTHER同士はLSDBを同期しないという設計どおりの状態です。

Waitタイマーの動作(STEP 2の開始時)

4台のOSPFプロセスを一斉にclear ospf 1 processで再起動した直後の状態です。

STEP 2 R4 選出前(Waitタイマー動作中)
RP/0/RP0/CPU0:R4#show ospf interface GigabitEthernet0/0/0/0
Sat Sep  5 14:08:24.096 UTC

GigabitEthernet0/0/0/0 is up, line protocol is up 
  Internet Address 10.0.0.4/24, Area 0, SID 0, Strict-SPF SID 0
  Label stack Primary label 0 Backup label 0 SRTE label 0
  Process ID 1, Router ID 4.4.4.4, Network Type BROADCAST, Cost: 1
  Transmit Delay is 1 sec, State WAITING, Priority 255, MTU 1500, MaxPktSz 1500
  Forward reference No, Unnumbered no,  Bandwidth 1000000 
  RIB LC sync Yes
  No designated router on this network
  No backup designated router on this network
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    Hello due in 00:00:06:809
    Wait time before Designated router selection 00:00:37
  Index 1/1, flood queue length 0
  Next 0(0)/0(0)
  Last flood scan length is 0, maximum is 1
  Last flood scan time is 0 msec, maximum is 0 msec
  LS Ack List: current length 0, high water mark 4
  Neighbor Count is 0, Adjacent neighbor count is 0
  Suppress hello for 0 neighbor(s)
  Multi-area interface Count is 0
  Segment Routing Forwarding MPLS enabled: Yes
  Adjacency hold timer expired last : Never
  Exchange timer expired last : Never

このときのR4のshow出力

State WAITINGで、DR・BDRはまだ決まっていません(No designated router on this network)。Wait time before Designated router selectionが選出までの残り時間で、Waitタイマーの40秒から減っていきます。この間に他のルータのHelloを聞き、プライオリティを把握してから選出が行われます。

なおこの出力は、次の「後からプライオリティを上げてもDRは変わらない」でR4のプライオリティを255にした状態のものです。

使われるマルチキャストアドレス

STEP 6まで終えてR1がDR・R2がBDRに戻った状態で、R3–SW間のリンクでキャプチャし、DROTHERであるR3のOSPFプロセスだけを再起動してLSAをやり取りさせました。R3はプライオリティ0なので、再起動してもDR/BDRの顔ぶれは変わりません。

キャプチャの冒頭(ospf-dr-bdr-multicast.pcap)
    1   0.000000     10.0.0.3 → 224.0.0.5    OSPF 122 Hello Packet
    2   0.203569     10.0.0.2 → 224.0.0.5    OSPF 122 Hello Packet
    3   1.238195     10.0.0.1 → 224.0.0.5    OSPF 122 Hello Packet
    4   1.337437     10.0.0.4 → 224.0.0.5    OSPF 122 Hello Packet
    5   7.288566     10.0.0.3 → 224.0.0.6    OSPF 110 LS Update
    6   7.288871     10.0.0.3 → 10.0.0.4     OSPF 78 DB Description
    7   7.295265     10.0.0.1 → 224.0.0.5    OSPF 110 LS Update
    8   7.301454     10.0.0.3 → 224.0.0.5    OSPF 110 Hello Packet
    9   7.357886     10.0.0.1 → 224.0.0.5    OSPF 98 LS Update
   10   9.299194     10.0.0.2 → 224.0.0.5    OSPF 98 LS Acknowledge
   11   9.300248     10.0.0.4 → 224.0.0.6    OSPF 98 LS Acknowledge

Helloは4台とも224.0.0.5宛です(No.1〜4)。DROTHERのR3とR4がLSAを送るときだけ224.0.0.6を使い(No.5、No.11)、DRのR1とBDRのR2は224.0.0.5を使っています(No.7、No.10)。

まず、DRのR1が送るHelloです。

No.3 Hello(R1 → 224.0.0.5)tshark -V
Ethernet II, Src: 52:54:00:fa:11:84, Dst: 01:00:5e:00:00:05
Internet Protocol Version 4, Src: 10.0.0.1, Dst: 224.0.0.5
        Message Type: Hello Packet (1)
        Source OSPF Router: 1.1.1.1
        Network Mask: 255.255.255.0
        Hello Interval [sec]: 10
        Router Priority: 100
        Router Dead Interval [sec]: 40
        Designated Router: 10.0.0.1
        Backup Designated Router: 10.0.0.2
        Active Neighbor: 2.2.2.2
        Active Neighbor: 3.3.3.3
        Active Neighbor: 4.4.4.4
上のtshark出力のパケット(No.3 Hello)のpcapをダウンロード

DR/BDRの選出に使われるRouter Priorityと、選出結果であるDesignated Router / Backup Designated RouterがHelloに載っています。DR/BDRはルータIDではなくインタフェースアドレスで書かれる点に注意してください。

次に、DROTHERのR3が自分のRouter-LSAを送るLSUです。

No.5 LSU(R3 → 224.0.0.6)tshark -V
Ethernet II, Src: 52:54:00:d5:27:8b, Dst: 01:00:5e:00:00:06
Internet Protocol Version 4, Src: 10.0.0.3, Dst: 224.0.0.6
        Message Type: LS Update (4)
        Source OSPF Router: 3.3.3.3
        LSA-type 1 (Router-LSA), len 48
            Link State ID: 3.3.3.3
            Advertising Router: 3.3.3.3
            Sequence Number: 0x80000002
上のtshark出力のパケット(No.5 LSU)のpcapをダウンロード

宛先が224.0.0.6で、イーサネットの宛先MACアドレスも01:00:5e:00:00:06になっています。このパケットはDRとBDRだけが受け取り、DROTHERのR4は受け取りません。

その7ミリ秒後、DRのR1が同じLSAを224.0.0.5宛で送り直しています。

No.7 LSU(R1 → 224.0.0.5)tshark -V
Ethernet II, Src: 52:54:00:fa:11:84, Dst: 01:00:5e:00:00:05
Internet Protocol Version 4, Src: 10.0.0.1, Dst: 224.0.0.5
        Message Type: LS Update (4)
        Source OSPF Router: 1.1.1.1
        LSA-type 1 (Router-LSA), len 48
            Link State ID: 3.3.3.3
            Advertising Router: 3.3.3.3
            Sequence Number: 0x80000002
上のtshark出力のパケット(No.7 LSU)のpcapをダウンロード

Source OSPF RouterはR1(1.1.1.1)ですが、中に入っているLSAはAdvertising Router: 3.3.3.3、シーケンス番号も0x80000002でNo.5とまったく同じものです。DRがDROTHERから受け取ったLSAをそのままセグメント全体へ中継している、という動きがパケットで確認できます。

最後に、BDRのR2が返すLSAckです。

No.10 LSAck(R2 → 224.0.0.5)tshark -V
Ethernet II, Src: 52:54:00:58:41:41, Dst: 01:00:5e:00:00:05
Internet Protocol Version 4, Src: 10.0.0.2, Dst: 224.0.0.5
        Message Type: LS Acknowledge (5)
        Source OSPF Router: 2.2.2.2
    LSA-type 1 (Router-LSA), len 48
        Link State ID: 3.3.3.3
        Advertising Router: 3.3.3.3
        Sequence Number: 0x80000002
    LSA-type 2 (Network-LSA), len 36
        Link State ID: 10.0.0.1
        Advertising Router: 1.1.1.1
        Sequence Number: 0x80000004
上のtshark出力のパケット(No.10 LSAck)のpcapをダウンロード

BDRは中継こそしませんが、自分が送るパケットの宛先は224.0.0.5です。224.0.0.6を使うのはDROTHERだけ、と覚えておけば間違いありません。

後からプライオリティを上げてもDRは変わらない(STEP 1〜2)

DROTHERのR4に、4台の中で最も高いプライオリティ255を設定します(STEP 1)。

STEP 1 R4に投入した設定
router ospf 1
 area 0
  interface GigabitEthernet0/0/0/0
   priority 255
  !
 !
!

60秒待ってから状態を確認します。

STEP 1 R4 プライオリティ255設定後
RP/0/RP0/CPU0:R4#show ospf interface
Sat Sep  5 14:07:49.089 UTC

Interfaces for OSPF 1

Loopback0 is up, line protocol is up 
  Internet Address 4.4.4.4/32, Area 0, SID 0, Strict-SPF SID 0
  Label stack Primary label 0 Backup label 0 SRTE label 0
  Process ID 1, Router ID 4.4.4.4, Network Type LOOPBACK, Cost: 1
  Loopback interface is treated as a stub Host
  Multi-area interface Count is 0
GigabitEthernet0/0/0/0 is up, line protocol is up 
  Internet Address 10.0.0.4/24, Area 0, SID 0, Strict-SPF SID 0
  Label stack Primary label 0 Backup label 0 SRTE label 0
  Process ID 1, Router ID 4.4.4.4, Network Type BROADCAST, Cost: 1
  Transmit Delay is 1 sec, State DROTHER, Priority 255, MTU 1500, MaxPktSz 1500
  Forward reference No, Unnumbered no,  Bandwidth 1000000 
  RIB LC sync Yes
  Designated Router (ID) 1.1.1.1, Interface address 10.0.0.1
  Backup Designated router (ID) 2.2.2.2, Interface address 10.0.0.2
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    Hello due in 00:00:07:642
  Index 1/1, flood queue length 0
  Next 0(0)/0(0)
  Last flood scan length is 0, maximum is 1
  Last flood scan time is 0 msec, maximum is 0 msec
  LS Ack List: current length 0, high water mark 4
  Neighbor Count is 3, Adjacent neighbor count is 2
    Adjacent with neighbor 1.1.1.1  (Designated Router)
    Adjacent with neighbor 2.2.2.2  (Backup Designated Router)
  Suppress hello for 0 neighbor(s)
  Multi-area interface Count is 0
  Segment Routing Forwarding MPLS enabled: Yes
  Adjacency hold timer expired last : Never
  Exchange timer expired last : Never

プライオリティは255になっているのに、状態はDROTHERのままです。DRはR1のまま変わりません。すでに選出が済んでいるセグメントでは、あとから高いプライオリティのルータが現れても再選出は起きないためです。

続けて4台すべてでclear ospf 1 processを実行し、全員を同時に選出からやり直させます(STEP 2)。

ルータプライオリティSTEP 1(再選出前)STEP 2(再選出後)
R1100DRBDR
R250BDRDROTHER
R30DROTHERDROTHER
R4255DROTHERDR

今度はプライオリティどおりR4がDRになりました。設定を変えただけでは切り替わらず、選出をやり直して初めて反映されるということです。実運用では、DRを意図した機器に固定したい場合、OSPFを有効にする前にプライオリティを設定しておく必要があります。

この「やり直し」は、4台のWaitタイマー(40秒)が重なっている必要があります。検証では4台へ順番にコマンドを送ったところ、先に再起動したR1がWaitタイマーの満了で自分をDRに決めてしまい、あとから参加したR4はBDRにしかなれませんでした。4台へ同時にコマンドを送り直すと、全台がWAITINGの間にプライオリティを知り、R4がDRになります。実機でも「一斉に落として上げる」ができない限り、意図した機器がDRになるとは限りません。

この確認のあと、R4のプライオリティは既定値に戻し、再度4台でclear ospf 1 processを実行してR1がDR、R2がBDRの状態に戻しています(STEP 3)。

DRがダウンしたときの動作(STEP 4〜5)

DRであるR1のGi0/0/0/0をshutdownします(STEP 4)。R2–SW間のリンクでキャプチャを取りながら実行しました。

STEP 4 R1に投入した設定
interface GigabitEthernet0/0/0/0
 shutdown
!

80秒後のR2の状態です。

STEP 4 R2 DRダウン後
RP/0/RP0/CPU0:R2#show ospf interface
Sat Sep  5 14:16:17.513 UTC

Interfaces for OSPF 1

Loopback0 is up, line protocol is up 
  Internet Address 2.2.2.2/32, Area 0, SID 0, Strict-SPF SID 0
  Label stack Primary label 0 Backup label 0 SRTE label 0
  Process ID 1, Router ID 2.2.2.2, Network Type LOOPBACK, Cost: 1
  Loopback interface is treated as a stub Host
  Multi-area interface Count is 0
GigabitEthernet0/0/0/0 is up, line protocol is up 
  Internet Address 10.0.0.2/24, Area 0, SID 0, Strict-SPF SID 0
  Label stack Primary label 0 Backup label 0 SRTE label 0
  Process ID 1, Router ID 2.2.2.2, Network Type BROADCAST, Cost: 1
  Transmit Delay is 1 sec, State DR, Priority 50, MTU 1500, MaxPktSz 1500
  Forward reference No, Unnumbered no,  Bandwidth 1000000 
  RIB LC sync Yes
  Designated Router (ID) 2.2.2.2, Interface address 10.0.0.2
  Backup Designated router (ID) 4.4.4.4, Interface address 10.0.0.4
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    Hello due in 00:00:06:731
  Index 1/1, flood queue length 0
  Next 0(0)/0(0)
  Last flood scan length is 1, maximum is 1
  Last flood scan time is 0 msec, maximum is 0 msec
  LS Ack List: current length 0, high water mark 4
  Neighbor Count is 2, Adjacent neighbor count is 2
    Adjacent with neighbor 3.3.3.3
    Adjacent with neighbor 4.4.4.4  (Backup Designated Router)
  Suppress hello for 0 neighbor(s)
  Multi-area interface Count is 0
  Segment Routing Forwarding MPLS enabled: Yes
  Adjacency hold timer expired last : Never
  Exchange timer expired last : Never

BDRだったR2がDRに昇格し、残ったルータから新しいBDRとしてR4が選ばれました。R3はプライオリティ0なのでBDRにもなれず、プライオリティ1のR4が選ばれています。

ログには、R1がDeadタイマー満了で落ちたことだけが記録されます。

STEP 4 R2 のログ
RP/0/RP0/CPU0:Sep  5 14:15:01.234 UTC: ospf[1035]: %ROUTING-OSPF-5-ADJCHG : Process 1, Nbr 1.1.1.1 on GigabitEthernet0/0/0/0 in area 0 from FULL to DOWN, Neighbor Down: dead timer expired, vrf default vrfid 0x60000000 

R1をshutdownしたのが14:14:21で、R2がR1のダウンを検知したのが14:15:01です。ちょうど40秒(Deadインターバル)かかっています。 R1は自分のインタフェースを落としただけで、スイッチを挟んだ他のルータから見るとリンクは上がったままなので、Helloが途絶えたことをDeadインターバルの満了で判断するしかないためです。

キャプチャでも同じことが確認できます。R1の最後のHelloと、切り替わった後のR2のHelloを並べます。

HelloのDR/BDRフィールドの変化(ospf-dr-bdr-failover.pcap)
No.   時刻     送信元      Designated Router   Backup Designated Router
7     11.600   10.0.0.1    10.0.0.1            10.0.0.2
19    28.165   10.0.0.4    10.0.0.1            10.0.0.2
26    38.737   10.0.0.2    10.0.0.1            10.0.0.2
30    47.909   10.0.0.2    10.0.0.1            10.0.0.2
31    48.293   10.0.0.3    10.0.0.1            10.0.0.2
42    56.270   10.0.0.4    10.0.0.2            10.0.0.2
43    57.811   10.0.0.2    10.0.0.2            10.0.0.4
44    58.246   10.0.0.3    10.0.0.2            10.0.0.4

上の表のNo.7(R1の最後のHello)のpcapをダウンロード

上の表のNo.43(切り替え後のHello)のpcapをダウンロード

No.7がR1の最後のHelloで、以降R1のHelloは止まります。それでもNo.31(約37秒後)まで、他のルータはHelloに10.0.0.1をDRとして載せ続けています。Deadインターバルが満了したあとのNo.42以降で、DRが10.0.0.2、BDRが10.0.0.4に切り替わりました。

最後に、R1のインタフェースをno shutdownで復旧させます(STEP 5)。

STEP 5 R1 復旧後
RP/0/RP0/CPU0:R1#show ospf interface
Sat Sep  5 14:19:37.643 UTC

Interfaces for OSPF 1

Loopback0 is up, line protocol is up 
  Internet Address 1.1.1.1/32, Area 0, SID 0, Strict-SPF SID 0
  Label stack Primary label 0 Backup label 0 SRTE label 0
  Process ID 1, Router ID 1.1.1.1, Network Type LOOPBACK, Cost: 1
  Loopback interface is treated as a stub Host
  Multi-area interface Count is 0
GigabitEthernet0/0/0/0 is up, line protocol is up 
  Internet Address 10.0.0.1/24, Area 0, SID 0, Strict-SPF SID 0
  Label stack Primary label 0 Backup label 0 SRTE label 0
  Process ID 1, Router ID 1.1.1.1, Network Type BROADCAST, Cost: 1
  Transmit Delay is 1 sec, State DROTHER, Priority 100, MTU 1500, MaxPktSz 1500
  Forward reference No, Unnumbered no,  Bandwidth 1000000 
  RIB LC sync Yes
  Designated Router (ID) 2.2.2.2, Interface address 10.0.0.2
  Backup Designated router (ID) 4.4.4.4, Interface address 10.0.0.4
  Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
    Hello due in 00:00:06:225
  Index 1/1, flood queue length 0
  Next 0(0)/0(0)
  Last flood scan length is 0, maximum is 2
  Last flood scan time is 0 msec, maximum is 0 msec
  LS Ack List: current length 0, high water mark 5
  Neighbor Count is 3, Adjacent neighbor count is 2
    Adjacent with neighbor 2.2.2.2  (Designated Router)
    Adjacent with neighbor 4.4.4.4  (Backup Designated Router)
  Suppress hello for 0 neighbor(s)
  Multi-area interface Count is 0
  Segment Routing Forwarding MPLS enabled: Yes
  Adjacency hold timer expired last : Never
  Exchange timer expired last : Never

プライオリティ100のR1が戻ってきても、DRはR2、BDRはR4のままで、R1はDROTHERになりました。ここでも再選出は起きません。DRが1台落ちるたびに役割が入れ替わっていくため、運用中のセグメントでは「どれがDRか」は設定値だけからは決まらないという点に注意が必要です。

最後にもう一度4台でclear ospf 1 processを実行し、R1がDR、R2がBDRの初期状態に戻しています(STEP 6)。

キャプチャーの全体は次の2本です。

R3–SW間のキャプチャ(ospf-dr-bdr-multicast.pcap) をダウンロード

R2–SW間のキャプチャ(ospf-dr-bdr-failover.pcap) をダウンロード

検証Configおよびshow結果

各STEPで4台すべてから、次の3種類をルータごとに分けて取得しています。検証Configはこの..._run.txtです(最終状態はSTEP 6のもの)。本文で引用しているのはこの一部です。

ファイル内容
..._show.txtshow version / show interface description / show route / show route ospf / show ospf / show ospf interface / show ospf interface brief / show ospf neighbor / show ospf neighbor detail / show ospf database / show ospf database router / show ospf database network / show ospf statistics interface
..._log.txtそのSTEPの範囲だけに絞ったshow logging。各STEPの開始時にlogmsgでマーカーを入れ、その時刻をshow logging startに指定して取得したもの(STEP 0のみ起動時からの全履歴)
..._run.txtそのSTEP時点のshow running-config(=そのSTEPの検証Config)

STEP 0:初期状態 — R1がDR、R2がBDR(本文: 選出結果DROTHER同士は2-Wayで止まる

ルータshow出力syslogrunning-config
R1showlogrun
R2showlogrun
R3showlogrun
R4showlogrun

STEP 1:R4のプライオリティを255に変更 — R1がDR、R2がBDRのまま変わらない(本文: 後からプライオリティを上げてもDRは変わらない

ルータshow出力syslogrunning-config
R1showlogrun
R2showlogrun
R3showlogrun
R4showlogrun

STEP 2:4台のOSPFプロセスを一斉に再起動 — R4がDR、R1がBDR(本文: Waitタイマーの動作後からプライオリティを上げてもDRは変わらない

ルータshow出力syslogrunning-config
R1showlogrun
R2showlogrun
R3showlogrun
R4showlogrun

STEP 3:R4のプライオリティを既定値に戻して一斉に再起動 — R1がDR、R2がBDRに復帰(本文: —)

ルータshow出力syslogrunning-config
R1showlogrun
R2showlogrun
R3showlogrun
R4showlogrun

STEP 4:R1のGi0/0/0/0をshutdown — R2がDRへ昇格、R4が新しいBDR(本文: DRがダウンしたときの動作

ルータshow出力syslogrunning-config
R1showlogrun
R2showlogrun
R3showlogrun
R4showlogrun

STEP 5:R1のGi0/0/0/0をno shutdown — R1はDROTHERとして復帰(DRはR2のまま)(本文: DRがダウンしたときの動作

ルータshow出力syslogrunning-config
R1showlogrun
R2showlogrun
R3showlogrun
R4showlogrun

STEP 6:4台のOSPFプロセスを一斉に再起動 — R1がDR、R2がBDRの初期状態へ復旧(本文: 最終状態。検証Configはこのrunning-config)

ルータshow出力syslogrunning-config
R1showlogrun
R2showlogrun
R3showlogrun
R4showlogrun

DR/BDRのプライオリティの設定方法は、別記事で解説します。

参考

RFCタイトル概要
RFC 2328OSPF Version 2DR/BDRの選出手順はSection 9.4(Electing the Designated Router)で定義されている。マルチキャストアドレスはSection A.1。

関連記事