Raspberry PI configuring Wi-Fi command-line

This was a saga… i bought myself a second hand USB dongle, a Dynamode WL-700N-XS ultra compact (nano) 802.11b/g/n compatible Wi-Fi adapter, based in tbe Realtek 8188CU chipset. A fully updated USB Wi-Fi adapters list is mantained here.

Dynamode Wireless USB Nano 150mbps WL-700N-XSThis chipset is pretty plug an play on the PI with the latest Raspbian Wheezy, reported to work directly with a decent power source, no driver compilation or obscure installation, just supported out of the box by the Linux kernel. Just perfect.

I confidently connect the dongle in the PI, the USB device was properly recognized:

# lsusb
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 0bda:8176 Realtek Semiconductor Corp. RTL8188CUS 802.11n WLAN Adapter

also on dmesg

# dmesg
[    3.171681] usb 1-1.2: new high-speed USB device number 4 using dwc_otg
[    3.293726] usb 1-1.2: New USB device found, idVendor=0bda, idProduct=8176
[    3.302266] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[    3.311142] usb 1-1.2: Product: 802.11n WLAN Adapter
[    3.317650] usb 1-1.2: Manufacturer: Realtek
[    3.323401] usb 1-1.2: SerialNumber: 00e04c000001
[   15.830604] usbcore: registered new interface driver rtl8192cu

and ifconfig, reports a wlan0, so by now everything looked great. I followed an tutorial about configuring wireless on PI, and no connection, then another, and no connection… shit!!! Then of course i dump the PI tutorials (you can guess the technical level as low when you find “reboot to load the new values”….). Moved to good old Linux documentation, as Raspbian is just another Debian clone.

So before messing with /etc/network/interfaces and /etc/wpa_supplicant/wpa_supplicant.conf the best debug tool is the command ‘iwlist wlan0 scan‘, that should print the available wireless networks. And with this dongle i was getting none (even at 10 centimeters of the wireless router). Long story short, after testing the dongle in other computers (and even other OS – yes, i washed my hands already) i found out the dongle is simply damaged and working rather randomly.

After replacing the dongle (thanks Delaman) by another of the exact same model, things started to work properly, iwlist wlan0 scan started to work right and i could see my wireless network, and the neighbors networks also.

From this point i could confidently resume the wireless network setup. First thing the /etc/network/interfaces:

auto lo
iface lo inet loopback

iface eth0 inet dhcp

auto wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

iface default inet dhcp

the important lines here are those 3 referring to the wlan interface and should be added to the configuration file.

Then the /etc/wpa_supplicant/wpa_supplicant.conf that holds the network security configuration. First i tried some of the suggested configurations in the Internets, but i was just getting the error: “failed to parse ssid ‘MY_NETWORK_NAME’” and the likes. So, go with the wpa_passphrase command to generate a network block configuration:

wpa_passphrase YOUR_NETWORK_NAME password

Now copy and replace the generated network block to /etc/wpa_supplicant/wpa_supplicant.conf, it should look something like this (a quite simple and clean configuration):

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev


You can heep the first two lines, as they provide an interface to the wpa_supplicant via the wpa_cli command.

Don’t have to reboot, i tested this while ethernet connected. Restart the wlan0 interface and reload the configuration into the supplicant thing:

ifdown wlan0
ifup wlan0
wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf

And there, ifconfig shows an active Wi-Fi connection on wlan0. From other computer, the wlan0 IP responds on pings and is possible to SSH. Now disable the ethernet connection:

ifdown eth0

disconnect the ethernet cable, and there your PI is free to move around without the network cable.

Leave a Reply