Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changing .netdev files and restarting has no effect if interface already exists #9627

Open
OtherSystems opened this issue Jul 17, 2018 · 12 comments
Labels
network RFE 🎁 Request for Enhancement, i.e. a feature request

Comments

@OtherSystems
Copy link

systemd version the issue has been seen with

239-5

Used distribution

debian stretch & debian sid

Expected behaviour you didn't see

when restarting systemd-networkd, the vlan does not reconfigured. When changing the vlan id in the .netdev file and restarting, the vlan on the interface stays the same.

Steps to reproduce the problem

setup a vlan using systemd-networkd
restart systemd-networkd and confirm vlan is created (ip -d link show)
change vlan id in the .netdev file of the vlan
restart systemd-networkd
observe the vlan id on the interface is still the intial vlan id and not the new one (ip -d link show)

@poettering
Copy link
Member

networkd uses .netdev files only to create network devices that are missing, and that's it. If you delete the vlan manually, then it should be set up again correctly

@poettering poettering changed the title vlan does not get reconfigered on restart of systemd-networkd changing .netdev files and restarting has no effect if interface already exists Jul 18, 2018
@yuwata yuwata added the RFE 🎁 Request for Enhancement, i.e. a feature request label Feb 26, 2019
@yuwata
Copy link
Member

yuwata commented Jan 7, 2020

Please use networkctl delete INTERFACE and networkctl reload.

@mweinelt
Copy link

mweinelt commented Apr 30, 2021

Please implement recreation of netdevs if their parameters mismatch. This is annoying, because it very easily goes unnoticed.

@lukas2511
Copy link

This also affects the wireguard configuration using systemd-networkd

Every time I want to add new peers or add new allowed ip ranges to existing peers I have to completely delete the wireguard interface and let systemd-networkd create it again. This disrupts existing connections on that interface, which makes it really annoying.

@SjonHortensius
Copy link
Contributor

Every time I want to add new peers or add new allowed ip ranges to existing peers I have to completely delete the wireguard interface and let systemd-networkd create it again. This disrupts existing connections on that interface, which makes it really annoying.

While not a solution, you can use this workaround if you're using separate dropins for your peers:

wg syncconf wg0 <(sed -e 's/WireGuardPeer/Peer/g' -e 's/WireGuard/Interface/g' /etc/systemd/network/*.netdev.d/*)

@znerol
Copy link

znerol commented Oct 29, 2021

you can use this workaround if you're using separate dropins for your peers

Nice!

@netravnen
Copy link

netravnen commented Dec 1, 2021

Please use networkctl delete INTERFACE and networkctl reload.

@yuwata

If systemd-networkd had a switch to force interface reconfiguration for already created (i.e. running) interfaces. This would be immensely helpful!

E.g. having separate commands for creating non-existing interfaces (the current default) and a switch argument in relation to networkctl reload detecting mismatches between the running interface state and the intended (*.net*-files) interface state.

Alternatively, being able to manually specify a command in the configuration files that systemd-networkd will execute when networkctl reload is run could also work. (i.e. delegating reconfiguring running interfaces to another process behind the scenes as specified by the user)

An example could be ReloadPolicy ,ReloadCmd, ReloadCommand, or ReloadScript. Similar to how ActivationPolicy exist. With Reload* accepting a full path to a script/command to be run when networkctl reload has been executed.

mweinelt added a commit to mweinelt/nixpkgs that referenced this issue Feb 21, 2022
Linux defaults to creating a `bond0` interface when modprobing the
`bonding` driver, because the `max_bonds` option defaults to `1`¹.

This `bond0` interface is created with the default bond mode
`balance-rr`, which is most often undesirable.
Networkd in turn is unable to change this mode, since it does not
implement netdev recreation on parameter mismatch².

If we instead default `max_bonds=0` the driver will be loaded, but no
default interface will be created, leaving networkd in a better position
to set up the network configuration.

[1] https://www.kernel.org/doc/Documentation/networking/bonding.txt
[2] systemd/systemd#9627
@grahamc
Copy link

grahamc commented Feb 22, 2022

This issue makes bonds a bit tricky. One of the default side-effects of loading the bonding kernel module is getting a bond0 "for free" in balance-rr mode.

A somewhat typical solution to this is to set some modprobe options to make bond0 the type you want. For example: options bonding mode=802.3ad. However, this makes the first bond a special case configuration-wise.

Another option is to set the misnamed "max_bonds" option to zero to disable the creation of bond0 altogether: options bonding max_bonds=0 and then correctly create the bond in userspace.

I just wanted to call out that NixOS is considering applying a patch which sets the default "max_bonds" to 0 at compile time: NixOS/nixpkgs#161281. This fits with our philosophy (and I think systemd's philosophy) of declarative configuration more nicely, at the expense of diverging from upstream's behavior.

@yuwata
Copy link
Member

yuwata commented Feb 22, 2022

We already provides options bonding max_bonds=0. See https://github.com/systemd/systemd/blob/db9ecf050165fd1033c6f81485917e229c4be537/modprobe.d/systemd.conf.

Note, I am slowly working on this RFE, and WIP PR is #22557.

mweinelt added a commit to mweinelt/nixpkgs that referenced this issue Feb 22, 2022
Linux defaults to creating a `bond0` interface when modprobing the
`bonding` driver, because the `max_bonds` option defaults to `1`¹.

This `bond0` interface is created with the default bond mode
`balance-rr`, which is most often undesirable.
Networkd in turn is unable to change this mode, since it does not
implement netdev recreation on parameter mismatch².

If we instead default `max_bonds=0` the driver will be loaded, but no
default interface will be created, leaving networkd in a better position
to set up the network configuration.

[1] https://www.kernel.org/doc/Documentation/networking/bonding.txt
[2] systemd/systemd#9627

Co-Authored-By: Graham Christensen <graham@grahamc.com>
@grahamc
Copy link

grahamc commented Feb 22, 2022

Thanks for the reference @yuwata, we've evidently missed this in our integration and are resolving that in NixOS/nixpkgs#161391. I appreciate it!

@vvrein
Copy link

vvrein commented Apr 13, 2022

Upd of this solution

wg syncconf wg0server <(sed -e 's/WireGuardPeer/Peer/g' -e 's/WireGuard/Interface/g' -e '/NetDev/d' -e '/Name/d' -e '/Kind/d' -e '/Description/d' -e '/RouteTable/d'  /etc/systemd/network/wg0server.netdev)

@mjt0k
Copy link

mjt0k commented Jul 3, 2023

Upd of this solution
wg syncconf wg0server <(sed -e 's/WireGuardPeer/Peer/g' -e 's/WireGuard/Interface/g' -e '/NetDev/d' -e '/Name/d' -e '/Kind/d' -e '/Description/d' -e '/RouteTable/d' /etc/systemd/network/wg0server.netdev)

A nice hack. It doesn't work when using PrivateKeyFile= though, - need to read that file and change the keyword to PrivateKey= .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
network RFE 🎁 Request for Enhancement, i.e. a feature request
Development

No branches or pull requests