NetworkManager: Difference between revisions

From NixOS Wiki
initial creation
 
Klinger (talk | contribs)
m typo
 
(11 intermediate revisions by 3 users not shown)
Line 1: Line 1:
NetworkManager is a suite of programs for configuring network devices on a system. It is widely used by several Linux distributions and can be optionally enabled on NixOS for non-declarative network configuration.
NetworkManager is a program for configuring network devices on Linux. It is widely used by several Linux distributions and can be optionally enabled on [[NixOS]] for non-declarative network configuration. It also tends to be the default for many desktop environments, such as [[GNOME]] or [[KDE|KDE Plasma]].
 
== Installation ==
NetworkManager can be enabled in the NixOS configuration file with the following line:<syntaxhighlight lang="nix">
networking.networkmanager.enable = true;
</syntaxhighlight>In order to allow access to the NetworkManager daemon and be able to configure and add new networks, the user must be added to the <code>networkmanager</code> group. This can be done through the <code>extraGroups</code> option for a defined user:<syntaxhighlight lang="nix">
users.users.<name>.extraGroups = [ "networkmanager" ];
</syntaxhighlight>By default, NetworkManager comes with <code>nmcli</code> and <code>nmtui</code> as user interfaces, however, a GTK interface called <code>nm-connection-editor</code> can be found in the <code>nm-applet</code> package.
 
== Usage ==
 
NetworkManager can be used with several front ends, such as <code>nmcli</code>, <code>nmtui</code>, or <code>nm-applet</code> and <code>nm-connection-editor</code>.
 
== Configuration ==
The NixOS modules offer additional configurations that can be setup very easily.
 
=== DNS Management ===
To allow custom DNS management, you must disable NetworkManager's built-in DNS resolution, as well as some NixOS <code>dhcp</code> related options. Refer to the configuration below as an example of what to do:<syntaxhighlight lang="nix">
networking.networkmanager.enable = true;
 
# Disable NetworkManager's internal DNS resolution
networking.networkmanager.dns = "none";
 
# These options are unnecessary when managing DNS ourselves
networking.useDHCP = false;
networking.dhcpcd.enable = false;
 
# Configure DNS servers manually (this example uses Cloudflare and Google DNS)
# IPv6 DNS servers can be used here as well.
networking.nameservers = [
  "1.1.1.1"
  "1.0.0.1"
  "8.8.8.8"
  "8.8.4.4"
];
</syntaxhighlight>
 
=== Power Saving ===
On laptops, where extra power savings may be desired, you can enable NetworkManager specific power saving options as follows:<syntaxhighlight lang="nix">
networking.networkmanager.wifi.powersave = true;
</syntaxhighlight>Please see [[Power Management]] for more tips relating to power-saving tips and tricks for NixOS.
[[Category:Networking]]
[[Category:Desktop]]
[[Category:GNOME]]
[[Category:KDE]]

Latest revision as of 18:10, 29 September 2024

NetworkManager is a program for configuring network devices on Linux. It is widely used by several Linux distributions and can be optionally enabled on NixOS for non-declarative network configuration. It also tends to be the default for many desktop environments, such as GNOME or KDE Plasma.

Installation

NetworkManager can be enabled in the NixOS configuration file with the following line:

networking.networkmanager.enable = true;

In order to allow access to the NetworkManager daemon and be able to configure and add new networks, the user must be added to the networkmanager group. This can be done through the extraGroups option for a defined user:

users.users.<name>.extraGroups = [ "networkmanager" ];

By default, NetworkManager comes with nmcli and nmtui as user interfaces, however, a GTK interface called nm-connection-editor can be found in the nm-applet package.

Usage

NetworkManager can be used with several front ends, such as nmcli, nmtui, or nm-applet and nm-connection-editor.

Configuration

The NixOS modules offer additional configurations that can be setup very easily.

DNS Management

To allow custom DNS management, you must disable NetworkManager's built-in DNS resolution, as well as some NixOS dhcp related options. Refer to the configuration below as an example of what to do:

networking.networkmanager.enable = true;

# Disable NetworkManager's internal DNS resolution
networking.networkmanager.dns = "none";

# These options are unnecessary when managing DNS ourselves
networking.useDHCP = false;
networking.dhcpcd.enable = false;

# Configure DNS servers manually (this example uses Cloudflare and Google DNS)
# IPv6 DNS servers can be used here as well.
networking.nameservers = [
  "1.1.1.1"
  "1.0.0.1"
  "8.8.8.8"
  "8.8.4.4"
];

Power Saving

On laptops, where extra power savings may be desired, you can enable NetworkManager specific power saving options as follows:

networking.networkmanager.wifi.powersave = true;

Please see Power Management for more tips relating to power-saving tips and tricks for NixOS.