NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.17k stars 14.19k forks source link

Switch to systemd-networkd #10001

Open edolstra opened 9 years ago

edolstra commented 9 years ago

Currently we have two implementations of the basic network options (like networking.interfaces), namely the old scripted implementation, and systemd-networkd. We should make the latter the default and (eventually) drop the former.

This would also remove dhcpcd and possibly replace openresolv by systemd-resolved.

ts468 commented 9 years ago

What's the timeline for it? I'm a little bit worried that by dropping the scripted implementation it gets quite hard to realize network setups that systemd-networkd was not specifically designed for. Network setups that can be realized within the scripted implementation, like, e.g., #10000, would have to be implemented, and upstreamed, in systemd-networkd. Well, I can clearly see the advantages of when things work within systemd-networkd, but I wouldn't rush to drop the currently scripted implementation.

edolstra commented 9 years ago

Note to self: we can remove the legacy nixos/modules/services/hardware/80-net-setup-link.rules when using systemd-networkd.

domenkozar commented 9 years ago

A good article explaining the benefits and path to migration https://tlhp.cf/systemd-networkd-migration-and-benchmarks/

domenkozar commented 8 years ago

Bumping milestone.

mrobbetts commented 8 years ago

Is there still a chance this will happen for 16.09?

domenkozar commented 8 years ago

Not really.

tadfisher commented 8 years ago

One argument in favor of rethinking the networking.* abstraction: https://github.com/NixOS/nixpkgs/issues/18962

groxxda commented 8 years ago

I'm really in favor of this switch, and am using networkd with nixos where it's possible already.

One big problem is: networkd is not suitable for (changing) wifi configuration. So for mobile devices we will still have to provide a non-networkd path. Imo it would be enough to recommend network-manager for this use case so we can drop most of the scripted stuff..

What do others think about this?

edolstra commented 8 years ago

Well, not being able to support wifi configurations makes it unsuitable as the default option at least...

tadfisher commented 7 years ago

Wifi config seems orthogonal to using networkd for base network configuration. Any interfaces not managed by networkd will continue to work in an unmanaged mode, which other daemons like NetworkManager can happily manage for you if you need easy wifi configuration.

dasJ commented 6 years ago

@edolstra networkd supports wifi now

arianvp commented 5 years ago

This is a blocker: https://github.com/NixOS/nixpkgs/issues/62034

NilsIrl commented 4 years ago

For someone that wants to use networkd now, what is the best guide/resource to follow?

I've tried

networking = {
  useDHCP = false;
  useNetworkd = true;
};

and it doesn't work.

dasJ commented 4 years ago

cc @haslersn maybe easily doable for you as you migrated our ansible infrastructure?

stale[bot] commented 4 years ago

Hello, I'm a bot and I thank you in the name of the community for opening this issue.

To help our human contributors focus on the most-relevant reports, I check up on old issues to see if they're still relevant. This issue has had no activity for 180 days, and so I marked it as stale, but you can rest assured it will never be closed by a non-human.

The community would appreciate your effort in checking if the issue is still valid. If it isn't, please close it.

If the issue persists, and you'd like to remove the stale label, you simply need to leave a comment. Your comment can be as simple as "still important to me". If you'd like it to get more attention, you can ask for help by searching for maintainers and people that previously touched related code and @ mention them in a comment. You can use Git blame or GitHub's web interface on the relevant files to find them.

Lastly, you can always ask for help at our Discourse Forum or at #nixos' IRC channel.

davidak commented 4 years ago

This is probably still a goal.

arianvp commented 4 years ago

Would it be possible for stalebot to skip milestoned issues?

mweinelt commented 4 years ago

A label would have to be added here https://github.com/NixOS/nixpkgs/blob/master/.github/stale.yml#L7.

nixos-discourse commented 3 years ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/state-of-systemd-networkd-networking-backend-in-nixos/10598/1

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

mweinelt commented 3 years ago

Not yet.

tv42 commented 3 years ago

For what it's worth, I've been using systemd-networkd exclusively with nixos-20.09 and nixos-21.05, to great success.

    networking.dhcpcd.enable = false;
    networking.useNetworkd = true;
    networking.useDHCP = false;

    # this keeps failing, both the binary and the finality of such state
    # is a fallacy anyway
    systemd.services."systemd-networkd-wait-online".enable = false;
nomeata commented 3 years ago

@tv42 Thanks! Is that really all you need to configure? It seems I still have to add lines like

  networking.interfaces.wlp0s20f3.useDHCP = true;

to make it work. Is there a way to tell systemd-networkd to manage all devices, even those that might be dynamically plugged in?

SebTM commented 3 years ago

I'm using a similar config to @tv42 and had to add: networking.wireless.interfaces = [ "wlp3s0" ];

kanashimia commented 3 years ago

to make it work. Is there a way to tell systemd-networkd to manage all devices, even those that might be dynamically plugged in?

This is what i use for example:

{ config, lib, ... }:

{
  networking = {
    useDHCP = false;
    useNetworkd = true;
  };

  systemd.network.networks = let
    networkConfig = {
      DHCP = "yes";
      DNSSEC = "yes";
      DNSOverTLS = "yes";
      DNS = [ "1.1.1.1" "1.0.0.1" ];
    };
  in {
    # Config for all useful interfaces
    "40-wired" = {
      enable = true;
      name = "en*";
      inherit networkConfig;
      dhcpV4Config.RouteMetric = 1024; # Better be explicit
    };
    "40-wireless" = {
      enable = true;
      name = "wl*";
      inherit networkConfig;
      dhcpV4Config.RouteMetric = 2048; # Prefer wired
    };
  };

  # Wait for any interface to become available, not for all
  systemd.services."systemd-networkd-wait-online".serviceConfig.ExecStart = [
    "" "${config.systemd.package}/lib/systemd/systemd-networkd-wait-online --any"
  ];
}

EDIT: the way systemd does *.network merging is weird

kanashimia commented 3 years ago

In my opinion networking.* is awful, it tries to abstract over networkd while having about 0 options, you can't even change DNS while using DHCP, can't set DNSSEC, DOT config.

Why try to invent a bicycle, why try to make some wrappers around networkd? Maybe instead we should just switch to networkd by itself, aka systemd.network.*? It would be much easier to maintain this.

What do you think?

edolstra commented 3 years ago

The networking.* options predate networkd. And the fact that these options exist is what allows us to switch to different networking implementations without invalidating every configuration.

nixos-discourse commented 3 years ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/status-of-networkd-as-default/3517/1

nixos-discourse commented 2 years ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/plans-for-the-networkd-infrastructure/23086/4

xaverdh commented 1 year ago

https://github.com/NixOS/nixpkgs/pull/202488 is trying to implement this

kacperwyczawski commented 6 months ago
# Wait for any interface to become available, not for all
systemd.services."systemd-networkd-wait-online".serviceConfig.ExecStart = [
   "" "${config.systemd.package}/lib/systemd/systemd-networkd-wait-online --any"
];

This can be achieved by systemd.network.wait-online.anyInterface = true; option too.

SebTM commented 6 months ago

202488 is trying to implement this

Latest PR trying to archive this: https://github.com/NixOS/nixpkgs/pull/264967

arianvp commented 5 months ago

This can be achieved by systemd.network.wait-online.anyInterface = true; option too.

This is now the default behaviour for networking.useNetworkd = true with networking.useDHCP = true