NetworkManager: Difference between revisions

From Alpine Linux
(replace /etc/init.d with rc-service)
(30 intermediate revisions by 9 users not shown)
Line 1: Line 1:
NetworkManager is a program that provides automatic detection and configuration for systems to connect to networks.
[https://networkmanager.dev/ NetworkManager] is a program that provides automatic detection and configuration for systems to connect to networks.


= Installation =
NetworkManager is in the repositories and can be installed with the {{Pkg|networkmanager}} package. It comes with a command line interface and a curses-based interface, <code>nmcli</code> and <code>nmtui</code> respectively.


Additional interfaces:
== Installation ==
* {{Pkg|plasma-nm}} for Plasma integration and applet
* {{Pkg|network-manager-applet}} for a GTK system tray applet


Start the daemon after installation:
{{Cmd|# apk add {{Pkg|networkmanager}}}}
<pre>rc-service networkmanager start</pre>
 
<br>
 
{{Note|
Networkmanager needs to have [[eudev|udev]] to be setup properly. The busybox implementation mdev is not sufficient. You can set up proper udev with:
{{Cmd|# setup-devd udev}}
Otherwise your network devices can be listed as (strictly-)unmanaged.
}}
 
There are multiple interfaces available for NetworkManager:
 
* TUI: {{Pkg|networkmanager-tui}}, a curses-based interface (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
 
<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>
 
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:
{{Cmd|# adduser <YourUsername> plugdev}}
 
{{Note|you will need to log out for the new group to take effect}}
 
<br>


== Wireless networks ==
== Wireless networks ==
NetworkManager supports wireless networks through {{Pkg|iwd}}. After installation, enable the server and restart NetworkManager:
 
==== wpa_supplicant backend ====
 
{{Todo|([[KDE|KDE Plasma]] Desktop) find out if it is possible to prevent requesting the password for '''KDE Wallet''' on login}}
 
* 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 <code>/etc/NetworkManager/NetworkManager.conf</code> in a text editor and change it to something like this:
 
{{Cat|/etc/NetworkManager/NetworkManager.conf|<nowiki>[main]
dhcp=internal
plugins=ifupdown,keyfile
 
[ifupdown]
managed=true
 
[device]
wifi.scan-rand-mac-address=yes
wifi.backend=wpa_supplicant</nowiki>}}
 
{{Note|if these options dont work on your system you can change them as necessary}}
 
<br>
 
Now you need to stop conflicting services:
 
{{Cmd|# rc-service networking stop}}
{{Cmd|# rc-service wpa_supplicant stop}}
 
<br>
 
Now restart NetworkManager:
 
{{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 del networking boot}}
{{Cmd|# rc-update del wpa_supplicant boot}}
 
<br>
 
==== iwd backend ====
 
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>
rc-service iwd start
rc-service iwd start
rc-service networkmanager restart
rc-service networkmanager restart
</pre>
</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}}:
<pre>
[device]
wifi.backend=iwd
</pre>
<br>


== VPN support ==
== VPN support ==
Line 23: Line 120:
Support for other VPN types is provided by plugins. They are provided in the following packages:
Support for other VPN types is provided by plugins. They are provided in the following packages:
* {{Pkg|networkmanager-openvpn}} for OpenVPN
* {{Pkg|networkmanager-openvpn}} for OpenVPN
== nm-applet ==
=== not authorized to control networking ===
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}}
Then, add following content to <code>/etc/NetworkManager/conf.d/any-user.conf</code>:
<pre>
[main]
auth-polkit=false
</pre>
Finally, restart networkmanager:
{{Cmd|# rc-service networkmanager restart}}




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

Revision as of 10:35, 17 November 2023

NetworkManager is a program that provides automatic detection and configuration for systems to connect to networks.


Installation

# apk add networkmanager


Note:

Networkmanager needs to have udev to be setup properly. The busybox implementation mdev is not sufficient. You can set up proper udev with:

# setup-devd udev

Otherwise your network devices can be listed as (strictly-)unmanaged.

There are multiple interfaces available for NetworkManager:


You will need to install an additional package if you want NetworkManager to connect to wifi:

# apk add networkmanager-wifi


After installation start NetworkManager:

# rc-service networkmanager start


Then set it to autostart the service on boot:

# rc-update add networkmanager default


Also 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


Wireless networks

wpa_supplicant backend

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


Note: wpa_supplicant configuration might not be required, if it isnt 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 you can 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 mentioned in Installation


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


VPN support

Since version 1.16, NetworkManager has support for Wireguard[1].

Support for other VPN types is provided by plugins. They are provided in the following packages:

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:

[main]
auth-polkit=false

Finally, restart networkmanager:

# rc-service networkmanager restart