NetworkManager: Difference between revisions

From Alpine Linux
(moved networking Prerequisites from introduction to its own section,fixed wiki tags, moved conflict explanation to introduction)
 
(37 intermediate revisions by 13 users not shown)
Line 1: Line 1:
[https://networkmanager.dev/ NetworkManager] is a program  that provides automatic detection and configuration for systems to connect to networks.
[https://networkmanager.dev/ NetworkManager] can be used to provide network management services in Alpine Linux. Ensure that only one network management service is running at a time to prevent conflicts between them.
 
== 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.
* Ensure that [[Configure Networking|network interfaces]] are configured and [[Configure_Networking#Connectivity_testing|tested]].


== Installation ==
== Installation ==


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


<br>
To be able to use NetworkManager with your current user (i.e. not root), you need to add your user to the <code>plugdev</code> group created by NetworkManager : {{Cmd|# adduser <YourUsername> plugdev}}
{{Note|If you are already logged in, you will need to relogin for the new group to take effect.}}


NetworkManager comes with a command line interface and a curses-based interface, <code>nmcli</code> and <code>nmtui</code> respectively or you can use a additional gui interface:
Some of the popular NetworkManager user interfaces or front ends available as sub-packages are:
* TUI: {{Pkg|networkmanager-tui}}, (run <code>nmtui</code>)
* Command line: {{Pkg|networkmanager-cli}} (run <code>nmcli</code>)
* GUI: {{Pkg|plasma-nm}} for Plasma integration and applet
* GUI: {{Pkg|network-manager-applet}} for a GTK system tray applet
{{Tip| Refer {{pkg|networkmanager-*}} for the list of all NetworkManager subpackages. [[Install]] the appropriate subpackages based on the required functionalities.}}


* {{Pkg|plasma-nm}} for Plasma integration and applet
== Networkmanager service ==
* {{Pkg|network-manager-applet}} for a GTK system tray applet


<br>
Start NetworkManager:{{Cmd|# rc-service networkmanager start}}
Set the service to autostart  on boot:{{Cmd|# rc-update add networkmanager default}}


After installation start NetworkManager:
== Wired networks ==
{{Cmd|# rc-service networkmanager start}}


<br>
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}}


== Wireless networks ==
== Wireless networks ==


==== wpa_supplicant backend ====
[[NetworkManager]] supports both wireless daemons i.e [[#iwd_backend|iwd]] and [[#wpa_supplicant_backend|wpa_supplicant]]. Using both daemons simulatenously leads to conflicts. First Install the {{Pkg|networkmanager-wifi}} package if you want NetworkManager to connect and manage wifi:{{Cmd|# apk add {{Pkg|networkmanager-wifi}}}}
 
* Follow: [[Wi-Fi#wpa_supplicant]] and [[Wi-Fi#Automatic_Configuration_on_System_Boot]]
{{Note|{{Pkg|wpa_supplicant}} configuration might not be required, if it isnt it may be a good idea to have it setup just as a fallback}}
 
<br>
 
Now open '''/etc/NetworkManager/NetworkManager.conf''' in a text editor and change it to something like this:


{{Cat|/etc/NetworkManager/NetworkManager.conf|<nowiki>[main]  
=== wpa_supplicant backend ===
{{Main|Wi-Fi}}
[[Wi-Fi#wpa supplicant|wpa supplicant]] is the default wifi daemon in Alpine Linux. Open {{path|/etc/NetworkManager/NetworkManager.conf}} in a text editor and change it to something like this: {{Cat|/etc/NetworkManager/NetworkManager.conf|<nowiki>[main]  
dhcp=internal
dhcp=internal
plugins=ifupdown,keyfile
plugins=ifupdown,keyfile
Line 41: Line 49:
wifi.backend=wpa_supplicant</nowiki>}}
wifi.backend=wpa_supplicant</nowiki>}}


{{Note|if these options dont work on your system you can change them as necessary}}
Now you need to stop conflicting services:{{Cmd|<nowiki># rc-service networking stop
# rc-service wpa_supplicant stop</nowiki>}}


<br>
Now restart NetworkManager:{{Cmd|# rc-service networkmanager restart}}


Now you need to stop conflicting services:
Now connect to a network using one of the interfaces configured. If that connects and stays connected with no issues add the <code>networkmanager</code> service and disable the <code>networking</code> and <code>wpa_supplicant</code> boot services:{{Cmd|<nowiki># rc-update add networkmanager default
# rc-update del networking boot
# rc-update del wpa_supplicant boot</nowiki>}}


{{Cmd|# rc-service networking stop}}
=== iwd backend ===
{{Cmd|# rc-service wpa_supplicant stop}}
{{Main|iwd}}
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.


<br>
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}}


Now 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
# rc-service networkmanager restart</noWiki>}}


{{Cmd|# rc-service networkmanager restart}}
== VPN support ==


<br>
NetworkManager has support for Wireguard and support for other VPN's are provided by plugins in the following subpackage:
* {{Pkg|networkmanager-openvpn}} for OpenVPN


Now connect to a network using one of the interfaces mentioned in [[NetworkManager#Installation|Installation]]
== Plasma support ==


<br>
{{Todo|([[KDE|KDE Plasma]] Desktop) find out if it is possible to prevent requesting the password for '''KDE Wallet''' on login}}
{{Todo|([[KDE|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}}


If that connects and stays connected with no issues enable the '''networkmanager''' service and disable the '''networking''' and '''wpa_supplicant''' boot services:
== Troubleshooting ==


{{Cmd|# rc-update add networkmanager}}
=== nm-applet not authorized to control networking ===
{{Cmd|# rc-update del networking boot}}
{{Cmd|# rc-update del wpa_supplicant boot}}


<br>
You can enable all users to edit connections without adding polkit.
First, make the <code>conf.d</code> directory for networkmanager: {{Cmd|# mkdir -p /etc/NetworkManager/conf.d}}


==== iwd backend ====
Then, add following content to {{path|/etc/NetworkManager/conf.d/any-user.conf}} so that {{cat|/etc/NetworkManager/conf.d/any-user.conf|[main]
auth-polkit{{=}}false}}


NetworkManager supports wireless networks through {{Pkg|iwd}}. After installation, enable the server and restart NetworkManager:
Finally, restart networkmanager: {{Cmd|# rc-service networkmanager restart}}
<pre>
rc-service iwd start
rc-service networkmanager restart
</pre>


To use {{Pkg|iwd}} though, you've have to edit NetworkManager's configuration because it still defaults to {{Pkg|wpa_supplicant}} instead. Add the following to {{Path|/etc/NetworkManager/NetworkManager.conf}}:
== See also ==
 
<pre>
[device]
wifi.backend=iwd
</pre>
 
<br>
 
== VPN support ==
Since version 1.16, NetworkManager has support for Wireguard[https://cgit.freedesktop.org/NetworkManager/NetworkManager/tree/NEWS?id=1.16.0].
 
Support for other VPN types is provided by plugins. They are provided in the following packages:
* {{Pkg|networkmanager-openvpn}} for OpenVPN


* [[Configure Networking|Networking]] - Main page
* [[Wifi#wpa_supplicant|wpa_supplicant]] - Default wifi daemon
* [[Iwd|iwd]] - An alternate wifi daemon


[[Category:Networking]]
[[Category:Networking]]

Latest revision as of 03:35, 29 March 2025

NetworkManager can be used to provide network management services in Alpine Linux. Ensure that only one network management service is running at a time to prevent conflicts between them.

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: If you are already logged in, you will need to relogin 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

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 default # 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