TTR Networks

Intermediate · OSPF on VyOS: costs and OSPFv3 · section 2 of 5

Costs and asymmetric routing

✓ Lab-tested 17 October 2026 on VyOS 2026.10.16-0024-rolling

OSPF picks the path with the lowest total cost. Every interface here has the default cost of 1, so core1 reaches edge1's loopback over the direct link, at a metric of 1.

Raise the cost of core1's link to edge1 to 100. Now the direct path costs 100, and the path through edge2 costs 1 + 1 = 2, so core1 switches. Its route to edge1's loopback now goes via eth1, towards edge2, at a metric of 2. Because core1 resolves its BGP next hops through OSPF, its default route moves too: internet traffic now goes core1 → edge2 → edge1 → upstream, as the traceroute from the LAN shows.

But look at edge1's route back to core1: still the direct link, at a metric of 1. Cost only applies in the direction you send. It's set per interface, on the sending router, so changing core1's cost changed core1's choices and nobody else's. Traffic to the internet goes one way and the replies come back the other: the path is now asymmetric. That's harmless for plain routing, but it breaks stateful firewalls that only see half of each connection (see Packets That Never Come Back). If you change a link's cost, usually change it on both ends.

In real networks, costs reflect link speed or preference: high cost on a backup or metered link, low cost on the main path. Plan them; don't leave everything at 1 by accident.

core1: raise the cost towards edge1
set protocols ospf interface eth0 cost '100'
  • Line 1: Only affects traffic core1 sends out of eth0.
core1 goes round (real output)
vyos@core1:~$ show ip route 198.51.100.242
Routing entry for 198.51.100.242/32
  Known via "ospf", distance 110, metric 2, best
  Last update 00:00:11 ago
  Flags: Selected
  Status: Installed
  * 198.51.100.226, via eth1, weight 1

vyos@core1:~$ show ip route 0.0.0.0/0
Routing entry for 0.0.0.0/0
  Known via "bgp", distance 200, metric 0, best
  Last update 00:00:11 ago
  Flags: Recursion iBGP Selected
  Status: Installed
    198.51.100.242 (recursive), weight 1
  *   198.51.100.226, via eth1, weight 1
  • Line 3: Metric 2: the path via edge2 is cheaper now.
  • Line 7: Via eth1, towards edge2.
  • Lines 15–16: The default route's BGP next hop (edge1) now resolves via edge2 as well.
…but edge1 doesn't (real output)
vyos@edge1:~$ show ip route 198.51.100.241
Routing entry for 198.51.100.241/32
  Known via "ospf", distance 110, metric 1, best
  Last update 00:03:06 ago
  Flags: Selected
  Status: Installed
  * 198.51.100.225, via eth1, weight 1
root@host:~# traceroute -n -q 1 203.0.113.130
traceroute to 203.0.113.130 (203.0.113.130), 30 hops max, 60 byte packets
 1  198.51.100.1  5.688 ms
 2  198.51.100.226  9.203 ms
 3  198.51.100.228  10.820 ms
 4  203.0.113.130  12.489 ms
  • Line 3: edge1 still uses the direct link back to core1, metric 1.
  • Line 11: From the LAN: core1, then edge2…
  • Lines 12–13: …then edge1 (its address on the edge1–edge2 link), then the internet.

Check your understanding

You set cost 100 on core1's interface towards edge1. Which traffic changes path?

  • Only traffic that core1 sends towards edge1
  • All traffic between core1 and edge1, both ways
  • Nothing until OSPF restarts
  • Only IPv6 traffic