How to Configure WPA2 Enterprise WiFi on Ubuntu Using nmcli

Connecting to a WPA2 Enterprise WiFi network on Ubuntu can seem daunting, especially for environments that require both a username and a password for access, such as universities or corporate offices. However, with the help of the Network Manager command-line interface (nmcli), this task becomes manageable. Here’s a detailed guide on how to set it up.

Prerequisites

  • A Debian-based system like Ubuntu with Network Manager installed.
  • Administrative (sudo) privileges on the system.
  • Knowledge of your WiFi interface name and the network SSID.

Step 1: Install Network Manager

First, ensure that Network Manager is installed on your system. You can install it using the command:

sudo apt update
sudo apt-get install network-manager

Step 2: Identify Your Wireless Interface

To configure your WiFi, you need to know the interface name of your wireless device. Run the following command to list all network interfaces:

nmcli device status

Look for the device type “wifi” in the output. The interface name is usually something like wlan0 or wlp3s0.

Step 3: Add a New WiFi Connection

Create a new connection profile for your WPA2 Enterprise network. Replace "Your_SSID", "Your_Username", and "Your_Password" with your network’s SSID, your username, and your password, respectively:

nmcli con add type wifi con-name "mywifi" ifname wlan0 ssid "Your_SSID"
nmcli con modify "mywifi" wifi-sec.key-mgmt wpa-eap
nmcli con modify "mywifi" 802-1x.eap peap
nmcli con modify "mywifi" 802-1x.phase2-auth mschapv2
nmcli con modify "mywifi" 802-1x.identity "Your_Username"
nmcli con modify "mywifi" 802-1x.password "Your_Password"

This command sequence sets up a new WiFi connection using PEAP and MSCHAPv2, which are common settings for WPA2 Enterprise.

Step 4: Enable and Test the Connection

Activate the connection with this command:

nmcli con up "mywifi"

Check the connection status to confirm you’re connected:

nmcli connection show
nmcli device wifi

Troubleshooting Tips

  • Connection Issues: If the connection fails, check your username and password, and ensure your network’s security settings are correctly mirrored in your nmcli commands.
  • Logs for Further Diagnosis: You can review detailed system logs with journalctl or check Network Manager’s logs for clues about any connection issues.

Conclusion

Using nmcli to configure WPA2 Enterprise on Ubuntu allows for a straightforward setup process that can be customized for different network requirements. Remember, each network might have specific settings related to its security protocol, so adjust the commands according to your network’s configuration.