Ubuntu-14.04 server + Raspberry Pi 2 + WiFi

This tutorial covers the configuration of a Raspberry Pi 2 loaded with Ubuntu 14.04 server (using wpa_supplicant) and configured with a USB WiFi dongle for wireless access.  This config is useful if we are running a head-less server where no Ethernet is available (or desired).


Hardware: Raspberry Pi 2, Model B, with Ubuntu 14.04 server installed on microSD
Realtek (RTl8192/8188CUS) Miniature WiFi (802.11b/g/n) Module (USB dongle)
Purchased from: Adafruit, cost = $12.00.
Note: Ubuntu (14.04) server does not come with the wpa_supplicant package installed, so let’s get it.

$ sudo apt-get install wpasupplicant

Use the default /etc/network/interfaces file as supplied in the Ubuntu image. Use the wired eth0 connection to do the initial RBPi configuration and updates. Then add configuration for the wlan0 static IP. Make sure the static wlan0 IP network config is placed BEFORE the “wpa-conf” statement.

You can test the wlan0 interface with DHCP first before moving to static. Note, after installing “wpasupplicant” you have to create the “wpa_supplicant.conf” file in “/etc”.

Here’s my working /etc/network/interfaces and /etc/wpa_supplicant.conf

# Working /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

# The loopback network interface
auto lo
iface lo inet loopback

auto wlan0

# The primary, wired network interface
# allow-hotplug eth0

## iface eth0 inet dhcp
# auto eth0
# iface eth0 inet static
# address
# netmask
# network
# broadcast
# gateway
# dns-nameservers

# Realtek USB Wifi module
allow-hotplug wlan0
# iface wlan0 inet dhcp

iface wlan0 inet static

Contents of: /etc/wpa_supplicant.conf

network={ ssid="your-network-ssid"  

Note: My wireless security protocol is WPA2 (wpa-psk)
The “protocol” could be either RSN (WPA2) or WPA (WPA1).
The “key_mgmt” could be either WPA-PSK (personal, most likely) or WPA-EAP (enterprise)
The “pairwise” could be either CCMP (WPA2) or TKIP (WPA1)
The “auth_alg” is most probably OPEN, other options are LEAP or SHARED
The initial Ethernet (eth0) static IP address was  

I used a wired connection plus static IP to do the initial server configurations (updates, add packages… etc.) The WiFi (wlan0) static IP address is Note that you cannot have 2 (eth0 and wlan0) interfaces active at once. So even if the eth0 cable is disconnected but you still reference that eth0 interface in /etc/network/interfaces config, the wireless interface will not come up.

So apply the initial configs (updates) with the wired connection (eth0) and add the wireless credentials (ssid + psk). Test the wlan0 interface by commenting out the eth0 interface in /etc/network/interfaces and disconnecting the wired connection.

Then reboot and test.