NetworkManager: Difference between revisions

From Alpine Linux
(fixed links, moved Todo related to KDE plasma to bottom of the page)
(reformatted headings and text to add clarity)
Line 1: Line 1:
[https://networkmanager.dev/ NetworkManager] is the standard Linux network configuration tool suite. [[NetworkManager]] supports both wireless daemons i.e [[#iwd_backend|iwd]] and [[#wpa_supplicant_backend|wpa_supplicant]]. Using both may lead to conflicts.
[https://networkmanager.dev/ NetworkManager] is the standard Linux network configuration tool suite. For the list of all NetworkManager subpackages refer {{pkg|networkmanager-*}}


== Installation ==
== Installation ==


{{Cmd|# apk add {{Pkg|networkmanager}}}}
Networkmanager needs to have [[eudev|udev]] to be setup properly. Otherwise your network devices can be listed as (strictly-)unmanaged.  
<br>
{{:Include:Setup Device Manager}}
{{Note| Networkmanager needs to have [[eudev|udev]] to be setup properly. Otherwise your network devices can be listed as (strictly-)unmanaged. The busybox implementation mdev is not sufficient. You can set up proper udev with:
{{Cmd|# setup-devd udev}}}}


There are multiple interfaces available for NetworkManager:
For Networkmanager to manage devices, your user needs to be in the <code>plugdev</code> group: {{Cmd|# adduser <YourUsername> plugdev}}
{{Note|you will need to log out for the new group to take effect}}


Install the basic Network Management daemon of NetworkManager suite:{{Cmd|# apk add {{Pkg|networkmanager}}}}
There are multiple user interfaces available in NetworkManager suite. Choose the appropriate subpackage:
* TUI: {{Pkg|networkmanager-tui}}, a curses-based interface (run <code>nmtui</code>)
* TUI: {{Pkg|networkmanager-tui}}, a curses-based interface (run <code>nmtui</code>)
* Command line: {{Pkg|networkmanager-cli}} (run <code>nmcli</code>)
* Command line: {{Pkg|networkmanager-cli}} (run <code>nmcli</code>)
* GUI: {{Pkg|plasma-nm}} for Plasma integration and applet
* GUI: {{Pkg|plasma-nm}} for Plasma integration and applet
* GUI: {{Pkg|network-manager-applet}} for a GTK system tray applet
* GUI: {{Pkg|network-manager-applet}} for a GTK system tray applet
For the list of all NetworkManager packages refer {{pkg|networkmanager-*}}
<br>
You will need to install an additional package if you want NetworkManager to connect to wifi:
{{Cmd|# apk add {{Pkg|networkmanager-wifi}}}}
<br>
After installation start NetworkManager:
{{Cmd|# rc-service networkmanager start}}


<br>
== Networkmanager service ==
Then set it to autostart the service on boot:
{{Cmd|# rc-update add networkmanager default}}
<br>


Also your user needs to be in the <code>plugdev</code> group:
Ensure that [[Configure Networking|network interfaces]] are configured and [[Configure_Networking#Connectivity_testing|tested]].
{{Cmd|# adduser <YourUsername> plugdev}}


{{Note|you will need to log out for the new group to take effect}}
Start NetworkManager:{{Cmd|# rc-service networkmanager start}}
<br>
Set the service to autostart  on boot:{{Cmd|# rc-update add networkmanager default}}


== Wired networks ==
== Wired networks ==
Line 42: Line 30:
managed{{=}}true
managed{{=}}true
}}
}}
<br>


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


==== wpa_supplicant backend ====
Install {{Pkg|networkmanager-wifi}} package if you want NetworkManager to connect and manage wifi:{{Cmd|# apk add {{Pkg|networkmanager-wifi}}}}


Refer the sections [[Wi-Fi#wpa supplicant|wpa supplicant]] and [[Wi-Fi#Automatic Configuration on System Boot|Automatic Configuration on System Boot]]. {{Pkg|wpa_supplicant}} configuration might not be required, if it isn't it may be a good idea to have it setup just as a fallback.
[[NetworkManager]] supports both wireless daemons i.e [[#iwd_backend|iwd]] and [[#wpa_supplicant_backend|wpa_supplicant]]. Using both may lead to conflicts.


Now open {{path|/etc/NetworkManager/NetworkManager.conf}} in a text editor and change it to something like this:
=== wpa_supplicant backend ===
{{Main|Wi-Fi}}
[[Wi-Fi#wpa supplicant|wpa supplicant]] is the default in Alpine Linux and can be [[Wi-Fi#Automatic_Configuration_on_System_Boot|configured to start]] on system boot.


{{Cat|/etc/NetworkManager/NetworkManager.conf|<nowiki>[main]  
{{Note|[[Wi-Fi#wpa supplicant|wpa supplicant]] might not be required, if it isn't it may be a good idea to have it setup just as a fallback.}}
 
Now 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 63: Line 54:
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.}}
{{Note|If these options dont work on your system, change them as necessary.}}
 
<br>


Now you need to stop conflicting services:
Now you need to stop conflicting services:
{{Cmd|# rc-service networking stop}}
{{Cmd|# rc-service networking stop}}
{{Cmd|# rc-service wpa_supplicant stop}}
{{Cmd|# rc-service wpa_supplicant stop}}


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


Now restart NetworkManager:
Now connect to a network using one of the interfaces configured. If that connects and stays connected with no issues enable the <code>networkmanager</code> service and disable the <code>networking</code> and <code>wpa_supplicant</code> boot services:
 
{{Cmd|# rc-service networkmanager restart}}
 
<br>
Now connect to a network using one of the interfaces mentioned in [[NetworkManager#Installation|Installation]]
<br>
 
If that connects and stays connected with no issues enable the <code>networkmanager</code> service and disable the <code>networking</code> and <code>wpa_supplicant</code> boot services:


{{Cmd|# rc-update add networkmanager}}
{{Cmd|# rc-update add networkmanager}}
Line 88: Line 68:
{{Cmd|# rc-update del wpa_supplicant boot}}
{{Cmd|# rc-update del wpa_supplicant boot}}


<br>
=== iwd backend ===
 
{{Main|iwd}}
==== iwd backend ====
{{Seealso|iwd}}
NetworkManager supports wireless networks through {{Pkg|iwd}}, however, consider [https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues?scope=all&utf8=%E2%9C%93&state=opened&search=iwd existing issues] before using it. After installation, enable the server and restart NetworkManager:
NetworkManager supports wireless networks through {{Pkg|iwd}}, however, consider [https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues?scope=all&utf8=%E2%9C%93&state=opened&search=iwd existing issues] before using it. After installation, enable the server and restart NetworkManager:
<pre>
<pre>
Line 105: Line 83:
</pre>
</pre>


<br>
== Todo ==
{{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}}


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


== Troubleshooting ==
== Troubleshooting ==
=== nm-applet not authorized to control networking ===
=== nm-applet not authorized to control networking ===


Line 121: Line 101:
{{Cmd|# mkdir -p /etc/NetworkManager/conf.d}}
{{Cmd|# mkdir -p /etc/NetworkManager/conf.d}}


Then, add following content to {{path|/etc/NetworkManager/conf.d/any-user.conf}}:
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}}
<pre>
[main]
auth-polkit=false
</pre>
 
Finally, restart networkmanager:


{{Cmd|# rc-service networkmanager restart}}
Finally, restart networkmanager: {{Cmd|# rc-service networkmanager restart}}
 
{{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}}


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

Revision as of 09:59, 10 January 2025

NetworkManager is the standard Linux network configuration tool suite. For the list of all NetworkManager subpackages refer networkmanager-*

Installation

Networkmanager needs to have udev to be setup properly. Otherwise your network devices can be listed as (strictly-)unmanaged. Setting up eudev on a desktop system is recommended in Alpine Linux. Without a fully functional device manager users will not be able to connect to input devices. The alpine-conf package provides setup-devd script to easily install and setup device managers.

Setup eudev.

# setup-devd udev

For more details and other options see eudev.

For Networkmanager to manage devices, your user needs to be in the plugdev group:

# adduser <YourUsername> plugdev

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

Install the basic Network Management daemon of NetworkManager suite:

# apk add networkmanager

There are multiple user interfaces available in NetworkManager suite. Choose the appropriate subpackage:

Networkmanager service

Ensure that network interfaces are configured and tested.

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 /etc/NetworkManager/NetworkManager.conf:

Contents of /etc/NetworkManager/NetworkManager.conf

[ifupdown] managed=true

Wireless networks

Install networkmanager-wifi package if you want NetworkManager to connect and manage wifi:

# apk add networkmanager-wifi

NetworkManager supports both wireless daemons i.e iwd and wpa_supplicant. Using both may lead to conflicts.

wpa_supplicant backend

wpa supplicant is the default in Alpine Linux and can be configured to start on system boot.

Note: wpa supplicant might not be required, if it isn't it may be a good idea to have it setup just as a fallback.

Now 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: If these options dont work on your system, change them as necessary.

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 enable 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 through iwd, however, consider existing issues before using it. After installation, enable the server and restart NetworkManager:

rc-service iwd start
rc-service networkmanager restart

To use iwd though, you've have to edit NetworkManager's configuration because it still defaults to wpa_supplicant instead. Add the following to /etc/NetworkManager/NetworkManager.conf:

[device]
wifi.backend=iwd

Todo

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


VPN support

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

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