Skip Navigation

NetworkManager

Out of the box, Alpine Linux uses ifupdown-ng to manage network interfaces and either wpa_supplicant or iwd to connect to WiFi networks. If a system uses both kinds of networks, however, it is convenient to have a single network management application. NetworkManager can be used for this purpose.

Page Contents

Network Management

A default installation of Alpine Linux uses ifupdown-ng to manage network interfaces. Since a server generally uses a wired network, and a container uses a virtual network, this tool is sufficient for network management. However, ifupdown-ng has a weakness when used with wireless networks or with machines that move between networks (like laptops), since it operates on the principle that the connection is established once and remains persistent.

For a stationary device that doesn’t roam between networks, ifupdown-ng can be combined with the wpa_supplicant to connect to a wireless network. The wpa_supplicant layer authenticates to the WiFi network, then ifupdown-ng triggers udhcpc, a DHCP client built into BusyBox, to obtain an IP address.

We can improve our WiFi experience on Alpine Linux by switching out this set of tools for the iNet Wireless Daemon (iwd), which was originally created by Intel. It is possible to run iwd in a standlone mode, in which it will use its own DHCP client to take care of configuring a wireless network interface. However, iwd in standalone mode is really only intended for wireless networks. Portable systems (such as laptops) might also connect to wired networks from time to time.

NetworkManager provides an easy way to manage both wired and wireless networks. It also includes its own DHCP client, although it can be configured to use an external DHCP client. For wireless authentication, NetworkManager can use either wpa_supplicant or iwd. Various front end applications can control NetworkManager over a D-Bus connection. These applications include the nmcli command-line tool, nmtui text-mode menu application, and various graphical applets for different desktop environments.

Installation

To install NetworkManager, its WiFi management component, and some useful interfaces, run:

doas apk add iwd networkmanager networkmanager-wifi networkmanager-tui networkmanager-cli

Configure iwd

In order to use iwd with NetworkManager, we first need to take it out of standalone mode. First, stop the iwd service:

doas rc-service iwd stop

Edit /etc/iwd/main.conf:

nvim /etc/iwd/main.conf

Be sure the following lines are commented out by ensuring that they start with a # symbol as shown below:

# EnableNetworkConfiguration=True
# NameResolvingService=resolvconf
# EnableIPv6=false

Now save your changes as root by using the :W command you previously created for Neovim.

Remove Networking Configuration

Edit /etc/network/interfaces to remove any interface configurations from ifupdown-ng. The only lines that should remain in the file are:

auto lo
iface lo inet loopback

Configure NetworkManager

Edit /etc/NetworkManager/NetworkManager.conf to read:

[main]
dhcp=internal
plugins=keyfile

[device]
wifi.scan-rand-mac-address=true
wifi.backend=iwd

These changes enable the keyfile plugin for NetworkManager and instruct it to use iwd as the WiFi connection backend. We also enable the use of randomly generated MAC addresses when scanning for wireless networks, as doing so improves privacy by making it harder for wireless access points to track our device when we aren’t associated. It is a good practice to enable it for laptops, phones, and other devices. Areas with public WiFi (such as grocery stores) are known to track devices (and therefore people) around the store by logging the MAC addresses used when scanning for wireless networks, even if you aren’t connected to the public WiFi service.

Start and Enable Services

We need both the iwd and NetworkManager services started and enabled:

doas rc-service iwd start
doas rc-update add iwd
doas rc-service networkmanager start
doas rc-update add networkmanager

Configure the Network

Start the menu-driven network configuration by running:

nmtui

Navigate to “Activate a Connection.” If you are plugged into a wired network, then a “Wired connection 1” connection is probably already active. Look for a single asterisk (*) next to the connection name to see if it is active. If you’re using WiFi and previously set up iwd manually, then you should find that your wireless connection is already activated.

If you don’t already have an active connection, proceed to the next sections.

Wired Network or Home/Phone WiFi

To activate your wired network, use the arrow keys to highlight the “Wired connection 1” option, then press Enter to activate it. For WiFi at home or using your cell phone hotspot, arrow down to your network name, then press Enter. You will be prompted for your wireless password.

Campus Wifi (eduroam)

Setting up NetworkManager and iwd for eduroam takes a bit more work, since eduroam is using WPA Enterprise authentication.

  1. Move the cursor to the right to select the Add button, then press Enter.
  2. Choose Wi-Fi from the menu, and press Enter.
  3. Change the Profile name to: eduroam
  4. Use the Tab key to navigate between fields.
  5. For the Device, enter: wlan0
  6. Tab down to the SSID field and set it to: eduroam
  7. Leave the Mode set to <Client>, and tab down to the <None> entry next to Security. Press Enter.
  8. Choose “WPA & WPA2 Enterprise” from the menu, and press Enter.
  9. Change the Authentication to PEAP.
  10. For the Anonymous Identity, enter your CCU email address.
  11. You can leave the Domain, CA cert, and CA cert password fields blank.
  12. Leave the PEAP version set to <Automatic> and the Inner authentication set to <MSCHAPv2>.
  13. Enter your CCU email address for the Username.
  14. Enter your CCU password for the Password.
  15. Leave everything else at the default settings, but be sure there is an X in the boxes next to “Automatically connect” and “Available to all users”.
  16. Navigate down to the OK button and press Enter.
  17. You will be returned to the connection editing menu, and you should now see eduroam under the Wi-Fi list. Navigate to the Back button, and press Enter.
  18. On the main menu, go to “Active a connection” and press Enter.
  19. On the list that appears, there should be a * next to eduroam under the Wi-Fi section. If there isn’t, then select eduroam, and press the Activate button. The star should now appear, indicating that you are connected. If not, check your username and password in the security settings inside the connection editor.

Exiting nmtui

To get out of nmtui, use the arrow keys to go to the Back button on the menu to get back to the main menu. Move down to the Quit entry on the main menu and press Enter to exit.

Displaying Connection Status

To display your network connection status easily, run:

nmcli connection show