1

All my servers' networking is configured via DHCP which sends, among others, a static route (needed for a VPN) and a gateway. This works fine.

I have one exception: a server which should not get the static route (but get everything else, ideally the gateway as well).

In order to deny the provided route(s), I added to its network config

[DHCP]
UseRoutes=false

This got rid of the static route (good) and also the default gateway (not good).

Ideally, I would like to receive the gateway from the DHCP server but I am OK to hardcode it in the configuration.

To this I tried several solutions, all of them failed (= the default route was not added)

  1. Add a Gateway= entry in the [Network] section:

[Match]
Name=br0

[Network]
DHCP=yes
Gateway=192.168.10.1

[DHCP]
UseRoutes=false
  1. Add an extra route, with something which looks like a "default":

[Match]
Name=br0

[Network]
DHCP=yes

[DHCP]
UseRoutes=false

[Route]
Gateway=192.168.10.1
Destination=default
# or, alternatively
# Destination=0.0.0.0/0

How can I add a default route to a DHCP configuration which denies the provided routes?

In other words, how to make systemd-networkd run something equivalent to ip r add default via 192.168.10.1?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.