OSPF the VyOS way
OSPF the VyOS way: interface-based configuration, reading the interface and database output, steering traffic with costs (and the asymmetric routing that follows), and OSPFv3 for IPv6 over link-local addresses. Captured on the three-router edge/core lab.
By the end you will be able to:
- Configure OSPFv2 on VyOS with interface-based areas, passive loopbacks and point-to-point links
- Read show ip ospf interface and the link-state database
- Steer traffic with interface costs, and recognise the asymmetric routing that one-sided costs cause
- Run OSPFv3 for IPv6 with global addresses only on loopbacks
Prerequisites: OSPF Fundamentals, Edge and core: building out a VyOS network
The OSPF fundamentals lesson used FRR's configuration language. VyOS runs the same FRR underneath, but you configure it through VyOS's set protocols ospf tree, which is interface-based: each interface is put into an area and given its options directly, instead of matching interfaces with network statements.
This lesson uses the three-router triangle from Edge and core: core1, edge1 and edge2, with loopbacks 198.51.100.241–243 and /31 links between them. (Its BGP and external sessions are still running, but you can ignore them here.) Every output comes from that lab.
The configuration is short:
parameters router-id: set it explicitly. The loopback address is the natural choice.interface lo area 0pluspassive: advertise the loopback, but don't send hellos on it.interface ethN area 0for each internal link, withnetwork point-to-point: two routers per link, so no Designated Router election (and the adjacency forms faster).
show ip ospf interface is the first place to look when an adjacency won't form. It shows the area, network type, cost, the hello and dead timers (10 and 40 seconds by default, and they must match on both ends), and how many neighbors are adjacent.
The link-state database holds one router LSA per router. On point-to-point links, each router LSA lists five links here: for each of its two neighbors, a point-to-point link plus a stub for the /31, and a stub for its loopback.
- Equal costs. Every link costs 1, so core1 reaches edge1 directly, at a metric of 1.
- Cost 100 on core1's side. The direct path now costs 100 from core1, and the path via edge2 only 2, so core1 goes round.
- But not on edge1's side. edge1's cost on the same link is still 1, so replies come straight back: asymmetric routing.
- OSPFv3 over link-local. For IPv6, OSPFv3 forms the same adjacencies over link-local addresses. Only the loopbacks have global IPv6.
set protocols ospf parameters router-id '198.51.100.241'
set protocols ospf interface lo area '0'
set protocols ospf interface lo passive
set protocols ospf interface eth0 area '0'
set protocols ospf interface eth0 network 'point-to-point'
set protocols ospf interface eth1 area '0'
set protocols ospf interface eth1 network 'point-to-point'- Line 1: Router ID = loopback.
- Lines 2–3: Advertise the loopback without sending hellos on it.
- Lines 4–7: Both internal links, point-to-point.
vyos@core1:~$ show ip ospf interface eth0
eth0 is up
ifindex 2, MTU 1500 bytes, BW 0 Mbit <UP,LOWER_UP,BROADCAST,RUNNING,MULTICAST>
Internet Address 198.51.100.225/31, Broadcast 255.255.255.255, Area 0.0.0.0
MTU mismatch detection: enabled
Router ID 198.51.100.241, Network Type POINTOPOINT, Cost: 1
Transmit Delay is 1 sec, State Point-To-Point, Priority 1
No backup designated router on this network
Multicast group memberships: OSPFAllRouters
Timer intervals configured, Hello 10s, Dead 40s, Wait 40s, Retransmit 5
Hello due in 7.658s
Neighbor Count is 1, Adjacent neighbor count is 1
Graceful Restart hello delay: 10s
LSA retransmissions: 3
vyos@core1:~$ show ip ospf database
OSPF Router with ID (198.51.100.241)
Router Link States (Area 0.0.0.0)
Link ID ADV Router Age Seq# CkSum Link count
198.51.100.241 198.51.100.241 159 0x8000000b 0xd89a 5
198.51.100.242 198.51.100.242 160 0x80000009 0x71ff 5
198.51.100.243 198.51.100.243 160 0x80000009 0xe782 5
vyos@core1:~$ show ip route 198.51.100.242
Routing entry for 198.51.100.242/32
Known via "ospf", distance 110, metric 1, best
Last update 00:02:34 ago
Flags: Selected
Status: Installed
* 198.51.100.224, via eth0, weight 1- Line 4: Address and area.
- Line 6: Point-to-point network type, cost 1.
- Line 10: Timers: must match the neighbor's.
- Line 12: One neighbor, fully adjacent.
- Lines 23–25: One router LSA per router, five links each.
- Lines 30–34: edge1's loopback, metric 1, over the direct link.
Check your understanding
On VyOS, how does an interface join OSPF area 0?
set protocols ospf interface eth0 area 0- A
networkstatement matching its subnet - Automatically, once it has an address
- Through BGP