NetworkManager: Difference between revisions

From Alpine Linux
(edited and moved the note location about not running networkmanager and wpa_supplicant services)
(consolidated the Prerequisites to its own section, reworded iwd section, removed redundant warnings)
Line 1: Line 1:
[https://networkmanager.dev/ NetworkManager] is the standard Linux network configuration tool suite.  
[https://networkmanager.dev/ NetworkManager] is the standard Linux network configuration tool suite. Ensure that [[Configure Networking|network interfaces]] are configured and [[Configure_Networking#Connectivity_testing|tested]] before you proceed to use NetworkManager.
 
== Prerequisites ==
 
* The [[Repositories#Managing_repositories|community repository must be enabled]].
* Set up [[eudev]]. Otherwise your network devices can be listed as (strictly-)unmanaged.
* A [[Setting_up_a_new_user#Creating_a_new_user|non-root user account]], is recommended.


== Installation ==
== Installation ==
Networkmanager needs to have [[eudev|udev]] to be setup properly. Otherwise your network devices can be listed as (strictly-)unmanaged.
{{:Include:Setup Device Manager}}


Install the basic network management daemon of NetworkManager suite:{{Cmd|# apk add {{Pkg|networkmanager}}}}
Install the basic network management daemon of NetworkManager suite:{{Cmd|# apk add {{Pkg|networkmanager}}}}
Line 19: Line 22:


== Networkmanager service ==
== Networkmanager service ==
Ensure that [[Configure Networking|network interfaces]] are configured and [[Configure_Networking#Connectivity_testing|tested]].


Start NetworkManager:{{Cmd|# rc-service networkmanager start}}
Start NetworkManager:{{Cmd|# rc-service networkmanager start}}
Line 27: Line 28:
== Wired networks ==
== Wired networks ==


If wired networks do not appear or you get an error message like "Could not activate connection: Connection 'Ethernet connection 1' is not available on device eth0 because device is strictly unmanaged", add the following to {{path|/etc/NetworkManager/NetworkManager.conf}}:
If wired networks do not appear or you get an error message like "Could not activate connection: Connection 'Ethernet connection 1' is not available on device eth0 because device is strictly unmanaged", add the following to the {{path|/etc/NetworkManager/NetworkManager.conf}} file as follows:{{Cat|/etc/NetworkManager/NetworkManager.conf|[ifupdown]
 
managed{{=}}true}}
{{Cat|/etc/NetworkManager/NetworkManager.conf|[ifupdown]
managed{{=}}true
}}


== Wireless networks ==
== Wireless networks ==
Line 65: Line 63:
=== iwd backend ===
=== iwd backend ===
{{Main|iwd}}
{{Main|iwd}}
NetworkManager supports wireless networks with [[iwd]] as backend, however, consider [https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues?scope=all&utf8=%E2%9C%93&state=opened&search=iwd existing issues] before using it.  
NetworkManager supports wireless networks with [[iwd]] daemon as backend, however, consider [https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues?scope=all&utf8=%E2%9C%93&state=opened&search=iwd existing issues] before using it.  
 
To use [[iwd]] as backend retain the NetworkManager's configuration file {{Path|/etc/NetworkManager/NetworkManager.conf}} as shown in [[#wpa_supplicant backend|previous section]] and modify that <code>[device]</code> section alone as follows: {{Cat|/etc/NetworkManager/NetworkManager.conf|...
[device]
wifi.backend{{=}}iwd
wifi.iwd.autoconnect{{=}}yes}}


Using both wireless daemons i.e [[Wi-Fi#wpa_supplicant|wpa_supplicant]] and [[iwd]] simultaneously lead to conflicts. Once iwd has been configured, ensure that [[Wi-Fi#Service_configuration|wpa_supplicant]] and related services are stopped before continuing. Start the iwd service and restart NetworkManager:
Ensure that [[Wi-Fi#Service_configuration|wpa_supplicant]] and related services are stopped before continuing. Start the iwd service and restart NetworkManager:
{{Cmd|<noWiki># rc-service iwd start
{{Cmd|<noWiki># rc-service iwd start
# rc-service networkmanager restart</noWiki>}}
# rc-service networkmanager restart</noWiki>}}
To use [[iwd]] as backend edit NetworkManager's configuration because it still defaults to [[Wi-Fi#wpa_supplicant|wpa_supplicant]]. Edit the file {{Path|/etc/NetworkManager/NetworkManager.conf}} and ensure that <code>[device]</code> section appears as follows: {{Cat|/etc/NetworkManager/NetworkManager.conf|[device]
wifi.backend{{=}}iwd
wifi.iwd.autoconnect{{=}}yes}}


== VPN support ==
== VPN support ==

Revision as of 16:09, 28 March 2025

NetworkManager is the standard Linux network configuration tool suite. Ensure that network interfaces are configured and tested before you proceed to use NetworkManager.

Prerequisites

Installation

Install the basic network management daemon of NetworkManager suite:

# apk add networkmanager

To be able to use NetworkManager with your current user (i.e. not root), you need to add your user to the plugdev group created by NetworkManager :

# adduser <YourUsername> plugdev

Note: you will need to log out for the new group to take effect

Some of the popular NetworkManager user interfaces or front ends available as sub-packages are:

Tip: Refer networkmanager-* for the list of all NetworkManager subpackages. Install the appropriate subpackages based on the required functionalities.

Networkmanager service

Start NetworkManager:

# rc-service networkmanager start

Set the service to autostart on boot:

# rc-update add networkmanager default

Wired networks

If wired networks do not appear or you get an error message like "Could not activate connection: Connection 'Ethernet connection 1' is not available on device eth0 because device is strictly unmanaged", add the following to the /etc/NetworkManager/NetworkManager.conf file as follows:

Contents of /etc/NetworkManager/NetworkManager.conf

[ifupdown] managed=true

Wireless networks

NetworkManager supports both wireless daemons i.e iwd and wpa_supplicant. Using both daemons simulatenously leads to conflicts. First Install the networkmanager-wifi package if you want NetworkManager to connect and manage wifi:

# apk add networkmanager-wifi

wpa_supplicant backend

wpa supplicant is the default wifi daemon in Alpine Linux. Open /etc/NetworkManager/NetworkManager.conf in a text editor and change it to something like this:

Contents of /etc/NetworkManager/NetworkManager.conf

[main] dhcp=internal plugins=ifupdown,keyfile [ifupdown] managed=true [device] wifi.scan-rand-mac-address=yes wifi.backend=wpa_supplicant
Note: Since networkmanager is an alternate for networking + wpa_supplicant services, running them simulatenously might cause conflicts.

Now you need to stop conflicting services:

# rc-service networking stop

# rc-service wpa_supplicant stop

Now restart NetworkManager:

# rc-service networkmanager restart

Now connect to a network using one of the interfaces configured. If that connects and stays connected with no issues add the networkmanager service and disable the networking and wpa_supplicant boot services:

# rc-update add networkmanager

# rc-update del networking boot

# rc-update del wpa_supplicant boot

iwd backend

NetworkManager supports wireless networks with iwd daemon as backend, however, consider existing issues before using it.

To use iwd as backend retain the NetworkManager's configuration file /etc/NetworkManager/NetworkManager.conf as shown in previous section and modify that [device] section alone as follows:

Contents of /etc/NetworkManager/NetworkManager.conf

... [device] wifi.backend=iwd wifi.iwd.autoconnect=yes

Ensure that wpa_supplicant and related services are stopped before continuing. Start the iwd service and restart NetworkManager:

# rc-service iwd start # rc-service networkmanager restart

VPN support

NetworkManager has support for Wireguard and support for other VPN's are provided by plugins in the following subpackage:

Plasma support

Todo: (KDE Plasma Desktop) find out if it is possible to prevent requesting the password for KDE Wallet on login


Todo: (KDE Plasma Desktop) for autoconnect to wifi network on start, it appears that the "all users may connect to this network" option must be selected in settings, as root is not a choice to allow. There are likely better workarounds


Troubleshooting

nm-applet not authorized to control networking

You can enable all users to edit connections without adding polkit.

First, make the conf.d directory for networkmanager:

# mkdir -p /etc/NetworkManager/conf.d

Then, add following content to /etc/NetworkManager/conf.d/any-user.conf so that

Contents of /etc/NetworkManager/conf.d/any-user.conf

[main] auth-polkit=false

Finally, restart networkmanager:

# rc-service networkmanager restart

See also