Today I learned

Managing Wi-Fi connections in Arch Linux with netctl

There's an alternative to using NetworkManager, and it's not too complicated to use

Many desktop systems rely on NetworkManager, but this isn't the only way to get a Linux system online. Arch Linux comes with netctla systemd-native way of managing physical network connections.

TLDR
# Open a menu to find Wi-Fi connections.
# This creates a profile and connects to it
sudo wifi-menu

# Auto connect on boot
# (Assuming 'wlp3s0' is your interface name)
sudo systemctl enable [email protected]

# Set it to auto-connect on boot
sudo netctl-auto enable wlp3s0-WifiNameHere

# To manuall yconnect to a wifi network:
sudo netctl-auto switch-to wlp3s0-WifiNameHere

Connecting to Wi-Fi

Use wifi-menu to set up a profile. Running it will bring a CLI menu of nearby Wi-Fi networks.

sudo wifi-menu

What's wifi-menu?

The wifi-menu is a utility to create netctl profiles. After selecting a network in wifi-menu, a profile will be created in /etc/netctl. After creating a profile, wifi-menu will automatically try to connect to it.

Only do this once per Wi-Fi network! After the profile's been created, you can connect to it without wifi-menu.

Enabling auto-roaming mode

Enable the netctl-auto@<interface> service to automatically connect to networks as they become in range. You may need to edit the profile files for this; check the (wiki entry) for more info.

sudo systemctl enable [email protected]

Connecting to profile manually

After creating a profile, you can connect to it using netctl switch-to <name>. The name is the name you provided in wifi-menu.

sudo netctl-auto switch-to wlp3s0-PrettyFly

Listing profiles

Use netctl-auto list to show what profiles have been created before.

$ sudo netctl-auto list

	wlp3s0-PrettyFly
	wlp3s0-Mashup Garage 2.4Ghz
	wlp3s0-Mashup Garage 5Ghz

Managing connections

Check for the status using iw devthis will list of your physical devices. This should show you what SSID you're connected to, if any.

$ iw dev

	phy#0
		Interface wlp3s0
			ifindex 2
			wdev 0x1
			addr e0:ac:ab:3f:db:ee
			ssid PrettyFly
			type managed

Auto-connecting a profile

Use netctl enable to "enable" a profile. This creates and enables a systemd service, which is invoked on every bootup.

$ sudo netctl enable wlp3s0-PrettyFly

	'/etc/systemd/systemd/multi-user.target.wants/netctl@wlp3s0\x2dPrettyFly.service' -> /usr/bin/systemd/netctl@service
	generated '/etc/sstemd/systemd/multi-user.target.wants/netctl@wlp3s0\x2dPrettyFly.service.d/profile.cnof'

Why use netctl?

For the most part, I find NetworkManager to be a preferrable choice over netctl for desktop systems. It works, it integrates with GNOME and Plasma, it has a lot of user interfaces (nmtui being my favoritea CLI version!), has support for OpenVPN, and many more.

With that said, I've been trying to use netctl instead lately for one silly reason: it seems to wake up faster from sleep! This only happens on my MacBook Air though, I've found NetworkManager to connect pretty fast in other systems.

There's also something to be said about going with a slimmer setup. Netctl seems a little closer to the metal than NetworkManager, and comes built-in as part of the base package in Arch Linux.


Epilogue

Thanks for reading my article! I've done some edits since this was first published.

  1. Used netctl-auto instead of netctl. This gets you the benefits of "roaming" (auto-switching connections) and more.

  2. Removed the use of netctl enable <profile>. This works, but will make your boot time slower (Arch will wait for the connection to become successful before finishing the boot process).

References

You have just read Managing Wi-Fi connections in Arch Linux with netctl, written on April 11, 2019. This is Today I Learned, a collection of random tidbits I've learned through my day-to-day web development work. I'm Rico Sta. Cruz, @rstacruz on GitHub (and Twitter!).

← More articles