0

How do I create multiple default routes, each with unique nexthop addresses?

I'm using Ubuntu 24.04.

With two IPv6 routers on a network, they each send their RA and my host creates two default routes, as follows:

$ ip -6 route 2001:2:0:1000::/64 dev enp0s9 proto kernel metric 256 expires 65531sec pref medium fe80::/64 dev enp0s9 proto kernel metric 256 pref medium default via fe80::200:10ff:fe10:1060 dev enp0s9 proto ra metric 1024 expires 595sec hoplimit 64 pref medium default via fe80::200:10ff:fe10:1061 dev enp0s9 proto ra metric 1024 expires 596sec hoplimit 64 pref medium 

When I try creating these manually, the 2nd default route returns an error:

$ sudo ip -6 route add default via fe80::200:10ff:fe10:1060 dev enp0s9 $ sudo ip -6 route add default via fe80::200:10ff:fe10:1061 dev enp0s9 RTNETLINK answers: File exists $ ip -6 route 2001:2:0:1000::/64 dev enp0s9 proto ra metric 1024 expires 64164sec pref medium fe80::/64 dev enp0s3 proto kernel metric 256 pref medium fe80::/64 dev enp0s9 proto kernel metric 256 pref medium default via fe80::200:10ff:fe10:1060 dev enp0s9 metric 1024 pref medium 

As you can see from the output, only the first default route is created.

1 Answer 1

0

I didn't find a way to manually create multiple defaults, but I could using systemd-networkd.

In my case, I have an interface enp0s9, so I edited the file /etc/systemd/network/10-enp0s9.network, adding the two route entries:

[Route] Gateway=fe80::200:10ff:fe10:1060 GatewayOnLink=true [Route] Gateway=fe80::200:10ff:fe10:1061 GatewayOnLink=true 

After reloading and reconfiguring, I can see both routes...

matt@ipv6logo-nut:~$ sudo networkctl reload matt@ipv6logo-nut:~$ sudo networkctl reconfigure enp0s9 matt@ipv6logo-nut:~$ ip -6 route # do NOT append "show dev enp0s9" fe80::/64 dev enp0s3 proto kernel metric 256 pref medium fe80::/64 dev enp0s9 proto kernel metric 256 pref medium default proto static metric 1024 pref medium nexthop via fe80::200:10ff:fe10:1060 dev enp0s9 weight 1 nexthop via fe80::200:10ff:fe10:1061 dev enp0s9 weight 1 

This is a little different to the kernel, since this appears to be a single default route entry, whereas the kernel creates two default route entries.

I'd still like to be able to replicate the kernel behavior from userspace, ie. creating two default route entries.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.