Setup wifi adapter in linux

This little guide should help with configuring a USB WiFi adapter in Linux – this was in Ubuntu 12.04 but should work for later releases and other Debian based Unix versions. I recently configured my Raspberry Pi to use a wiki dongle but this guide didn’t work for some reason. This guide still works though and is much preferable since it is entirely done on the command line. The Raspberry Pi guide (which I’ll add at a later date) makes use of some GUI elements so not great for a headless server use case.I use the Edimax EW7811-UN which is very cheap and complies with normal the 802.11b/g/n IEEE standards. The device has a Realtek RTL8188CUS based chipset which has support for Windows, Mac & Linux. It also works great in the Raspberry Pi.
When the device is inserted to a USB port on the machine, the rtl8192cu module should be loaded automatically.

Load wifi module driver
First, check if the driver is automatically loaded on your machine with

If the result shows that the “8192cu” driver module is loaded, you have nothing left to do to load the module. If the result is nil, continue.
If it shows some other “…8192…” driver, uninstall it with rmmod -r .
Find the latest linux driver download address from Edimax:
Go to the Edimax website
-> Downloads
-> Communications Network ICs
-> Wireless LAN ICs
-> WLAN NIC
-> IEEE 802.11b/g/n Single Chip
-> Software
-> “Software: Drivers and Utilities”
-> “Step 1. Select one or more models”: check the box by RTL8192CU) and use in the correct line below:

Insert the Edimax device into a USB port and check to see if the module has been loaded correctly automatically:

If nothing is returned, the module can be loaded manually:

Configure wifi connection

Install dependencies and kill network management utilities for configuration:

Perform the SSID & password config

-> then type your password

If you get your IP address automatically assigned by your router (most users) by DHCP just use the following (Note that you may have configured your router to assign a static IP to your server but from your server’s perspective this is still an auto assignation from your router so do this):

If you want to configure a static IP then use:

You should now be able to ping your router by IP:

Now add the default gateway using the IP address of your router:

You should be able to ping the net at large now (Google’s IP = 8.8.8.8):

Add DNS. This one is Google’s free DNS service which is pretty fast and reliable so a great choice – however there are privacy implications which we’ll not get into here). You could also use your ISP DNS servers which you should have been given when you joined them or which will be the ones defined in your ISP provided modem/router.

You should be done now, test by pinging Google:

Make persistent through a reboot

This will not last through a reboot, to make this persistent we need to make a little script:

Add this:

You should now add to crontab or rc.local to run at startup. Crontab is a task scheduling tool in linux, whereas rc.local is a script which runs at boot so you can add things to it to make them run at startup.
The easiest way I found to add to crontab is through Webmin (see this post for Webmin installation guide).

To manually add to crontab you can do this:

Or to add to rc.local:

Add this above ‘exit 0’:

Useful sources
http://www.cianmcgovern.com/getting-the-edimax-ew-7811un-working-on-linux/
http://askubuntu.com/questions/8568/can-ubuntu-server-connect-to-a-wpa2-encrypted-wireless-network/73025#73025

1 Comment

Leave a Reply

(email optional)