OSPF · Topic 2 of 4

OSPF Router ID, Adjacencies and DR/BDR

Learn OSPF router ID selection in Junos, neighbor states from Down to Full, the parameters that must match, and DR and BDR election with priority 128.

  • 6 min
In a nutshell
  • Router ID: configured value first, then the first interface to come up (usually lo0), then the first hardware interface.
  • Set the router ID with set routing-options router-id.
  • States: Down, Attempt, Init, 2Way, ExStart, Exchange, Loading, Full.

What it is

The router ID is a 32-bit number, written like an IPv4 address, that names an OSPF router uniquely in the domain. It appears in every LSA the router originates and in every hello it sends.

A neighbor is a router seen in hellos on a shared link. An adjacency is a neighbor relationship where the databases are synchronized, shown as state Full. On broadcast segments, a designated router (DR) and backup designated router (BDR) are elected so that every router forms full adjacencies only with them, not with each other.

Downhello seenInitown ID in hello2WayDR electionDR or BDR involvedExStartDBDExchangeLSRLoadingdoneFull

How it works

Router ID selection

Junos chooses the router ID in this order:

  1. The value set with set routing-options router-id.
  2. If none is set, an address of the first interface to come up, which is usually the loopback address on lo0.
  3. If there is no usable loopback address, the address of the first hardware interface with an IP address.
user@router# set interfaces lo0 unit 0 family inet address 192.168.0.1/32
user@router# set routing-options router-id 192.168.0.1

Setting the router ID explicitly, usually to the loopback address, keeps it stable across reboots and interface changes. Two routers with the same router ID cause flapping LSAs and missing routes, because each one keeps flooding its own version.

Neighbor states

StateMeaning
DownNo hello received recently
AttemptNBMA only; hellos sent to a configured neighbor
InitA hello was received, but it does not list this router's ID
2WayEach router sees its own ID in the other's hello; DR election happens here
ExStartMaster and slave chosen for the database exchange
ExchangeDBD packets describe each database
LoadingLSRs ask for missing LSAs
FullDatabases are synchronized

On a broadcast segment, two DROther routers stay in 2Way with each other. That is normal, not a fault.

What must match

Hellos carry parameters that both neighbors must agree on, or no adjacency forms.

ParameterMust match?
Area IDYes
Hello and dead intervalsYes; Junos defaults are 10 and 40 seconds
Area type (stub or NSSA flags)Yes
Authentication type and keyYes
Subnet maskYes on broadcast links; not checked on point-to-point links
Interface MTUYes; checked in DBD, so a mismatch stalls ExStart or Exchange
Router IDMust be different

DR and BDR election

Without a DR, a segment of n routers would need n(n minus 1)/2 adjacencies and a lot of duplicate flooding. With a DR, each router forms Full adjacencies only with the DR and BDR. The DR also originates the network LSA (type 2) for the segment.

Election happens in the 2Way state:

  1. The router with the highest priority becomes DR. The Junos default priority is 128; the range is 0 to 255.
  2. If priorities tie, the highest router ID wins.
  3. The runner-up becomes BDR.
  4. A router with priority 0 can never be DR or BDR.

The election is not preemptive. A router with a higher priority that joins later does not take over. It becomes DR only when the current DR and BDR fail.

DR failsBDR promotedNew DRnew electionNew BDR
user@router# set protocols ospf area 0.0.0.0 interface ge-0/0/0.0 priority 200
user@router# set protocols ospf area 0.0.0.0 interface ge-0/0/1.0 priority 0

Avoiding the DR on point-to-point Ethernet

Junos treats Ethernet interfaces as broadcast by default, so a DR is elected even on a link with only two routers. Setting the interface type to point-to-point removes the election and the wait before adjacency forms.

user@router# set protocols ospf area 0.0.0.0 interface ge-0/0/2.0 interface-type p2p

Both ends must use the same type, or the adjacency does not come up correctly.

Reading the neighbor table

user@router> show ospf neighbor
Address          Interface              State     ID               Pri  Dead
10.0.12.2        ge-0/0/0.0             Full      192.168.0.2      128    36
10.0.13.3        ge-0/0/1.0             2Way      192.168.0.3      128    33
10.0.14.4        ge-0/0/2.0             Init      192.168.0.4      128    38

The first neighbor is fully adjacent. The second is in 2Way, which is normal if neither router is DR or BDR on that segment. The third is in Init, so this router's hellos are not reaching it or are not being accepted.

show ospf interface shows the DR and BDR for each segment and this router's role:

user@router> show ospf interface
Interface           State   Area            DR ID           BDR ID          Nbrs
ge-0/0/0.0          BDR     0.0.0.0         192.168.0.2     192.168.0.1        1
lo0.0               DR      0.0.0.0         192.168.0.1     0.0.0.0            0
Exam tip

show ospf neighbor extensive adds the DR and BDR addresses, the neighbor's priority and how long the adjacency has been up, which helps when an adjacency keeps flapping.

Common mistakes

Treating 2Way as a fault. Between two DROther routers on a broadcast segment, 2Way is the correct final state.

Expecting a higher-priority router to take over the DR role. The election is not preemptive. The new router waits until the DR and BDR fail.

Changing the loopback and expecting no impact. If the router ID comes from the loopback, changing it changes the router ID and every LSA the router originates.

Watch out

A neighbor stuck in Init means hellos arrive in one direction only. Look for a firewall filter, a hello authentication mismatch on one side, or a one-way link fault.

What to remember for the exam

  • Router ID: configured value first, then the first interface to come up (usually lo0), then the first hardware interface.
  • Set the router ID with set routing-options router-id.
  • States: Down, Attempt, Init, 2Way, ExStart, Exchange, Loading, Full.
  • Area ID, hello and dead intervals, area type, authentication and MTU must match; the router ID must be unique.
  • DR election: highest priority (Junos default 128), then highest router ID; priority 0 never becomes DR.
  • The election is not preemptive; DROthers stay in 2Way with each other.
  • interface-type p2p removes the DR election on a two-router Ethernet link.

Check yourself

  • What is the default OSPF interface priority in Junos?

    128; a router with priority 0 can never become DR or BDR.

  • Two routers on a LAN are neither DR nor BDR. Which state do they show for each other?

    2Way, which is normal between DROther routers.

  • A neighbor shows Init. What does that mean?

    This router receives the neighbor's hellos, but those hellos do not list this router's ID, so communication works in one direction only.

Topic 2 of 4 in OSPF

Test yourself on OSPF

The full Juniper JNCIS-SP JN0-364 question bank has 860 questions, with timed practice exams and an explanation for every answer.

This study guide is independent and is not affiliated with, endorsed by, or sponsored by Juniper. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.