IllinoisNet Wireless – Command Line (Ubuntu 20.04)

Let Ubuntu connect to WPA2 Enterprise WiFi – command line

This time, I am using Raspberry Pi 3B+ to connect to the IllinoisNet (WiFi name in my school), which is a WPA2 Enterprise public network that requires your netid and your student account password (identity and password) to login and connect. On PC or mac, when users try to connect to this wifi, a window will pop up and ask for netid and password. But since there is no GUI in command-line version of Ubuntu, we need to try to add this information to “some file” in the syst

I managed to finish this based on this post. But since this tutorial is outdated, and there are some new commands that are different from the old ones, I hope this post can help you set up your machine. For the convenience of reading, I will copy original posts at some points.

Configuration:

Step 0: Check if your machine can connect to WiFi. I used the command ip a to check if I have the “network interface” connected (network interface is wlan0 on my machine). You can ignore this step if you know that your machine can connect to WiFi.

Step 1: Make sure wpa_supplicant is installed.

wpa_supplicant -v

My result:

wpa_supplicant v2.9
Copyright (c) 2003-2019, Jouni Malinen <j@w1.fi> and contributors

Most distros probably come with it. Here’s the command to install it in Ubuntu, what you need to do may be different depending on your package manager. But since you are trying to connect to WiFi at this point, if you don’t have wpa_supplicant installed in your machine at this point, my suggestion is to connect to another WiFi first. It can be your personal hotspot or normal WiFi (WPA2/WPA3 Personal) that requires only WiFi name and password to connect.

sudo apt-get install wpa_supplicant


Step 2: Create a config file for wpa_supplicant named “wpa_supplicant.conf”, you can make it anywhere but it’s usually placed in /etc/ or /etc/wpa_supplicant/. Here I’m creating it inside /etc/wpa_supplicant/

sudo touch /etc/wpa_supplicant/wpa_supplicant.conf


Step 3: Open up the file in a text editor.

Original post uses:

gksudo gedit /etc/wpa_supplicant/wpa_supplicant.conf

But since my machine couldn’t use gksudo and gedit, I used nano instead:

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

Tutorial for using Nano: https://linuxize.com/post/how-to-use-nano-text-editor/

You can also try vim to add this file if you are familiar with vim.

Step 4: Put the following into the file, replacing <your netid> with your NetID WITHOUT the “@illinois.edu” and <your password> with your password:

network={
      ssid="IllinoisNet"
      scan_ssid=1
      key_mgmt=WPA-EAP
      pairwise=CCMP TKIP
      group=CCMP TKIP
      eap=TTLS
      identity= "<your netid>"
      password= "<your password>"
      # ca_cert="/etc/ssl/certs/USERTrust_RSA_Certification_Authority.pem"
      phase2="auth=MSCHAPV2"
}

According to this page, I found that the “CA Certificate” is not mandatory for setting up this WiFi. So I comment down the “ca_cert” part above. If you failed because of this, you can try uncomment the line or try to add the certification manually. You can download the ca_cert here: http://go.illinois.edu/wificert. This is also given by the webpage above.

Note: The original post uses a different pem file. But according to another post, the older pem file has expired. So I put the recommended ca_cert aboved.

Refreshing and starting wpa_supplicant:

Step 5: Stop NetworkManager, existing instances of wpa_supplicant, and anything else that may be using the wireless card.

sudo service network-manager stop
sudo killall wpa_supplicant

Step 6: Bring down the interface and start fresh. Replace <interface> with the name of your wireless interface (it’s wlan0 on my machine).

# sudo ifconfig <interface> down
sudo ip link set <interface> down
sudo dhclient -r <interface>

Since I didn’t have ifconfig on my machine, I ignored the command sudo ifconfig wlan0 down and it still works fine. But the second line works fine for most Linux systems. Here is a tutorial I found for ip commands.


Step 7: Connect to IllinoisNet with wpa_supplicant. Once again, replace <interface> with the name of your interface. Also, change the file path to the .conf file if yours is in a different location

sudo wpa_supplicant -Dnl80211 -i<interface> -c/etc/wpa_supplicant/wpa_supplicant.conf -B


Step 8: Ask for an IP address. Again, <interface> is the name of your interface. Note, your GUI will give no visible indication whether you are connected or not. If this command terminates in a timely manner you probably succeeded.

sudo dhclient <interface>
When you're done and wish to restore to your original state, kill wpa_supplicant and restart NetworkManager.
sudo killall wpa_supplicant
sudo service network-manager start

Shell Script:

The .conf file will stay on your system after the first time, but you will have to go through steps 5-8 every time you connect to IllinoisNet. Going through this process each and every time you want to connect can get annoying. So instead of doing all this manually, after you create the .conf file, you can copy and paste the following into a shell script and just run the script each time you want to connect.

#!/bin/sh
# Script to set up connection to IllinoisNet
# Run as root
service network-manager stop
killall wpa_supplicant
# ifconfig wlan0 down
ip link set wlan0 down
dhclient -r wlan0
wpa_supplicant -Dnl80211 -iwlan0 -c/etc/wpa_supplicant/wpa_supplicant.conf -B
dhclient wlan0

The script should be run as root. Make sure execution is allowed:

sudo ./scriptname.sh

If the script fails to run, you can reboot and try again (that’s how I solved it).

If you wish to run this script on startup, you can follow tutorials online. Here is one tutorial I found for Ubuntu 20.04.

References: