Connecting Ubuntu to wireless networks from the command line
I usually use Linux with IceWM window manager without Gnome nor KDE desktop environments, where I have to manually connect to wireless networks using console commands. Here, I show how I do it. This tip should be also useful if you are working under non-graphical session and needing a wireless network connection, such as in case of headless servers or embedded systems.
Method
First, check our wireless interface name and access points:
$ sudo iwlist scan
ra0 Scan completed :
Cell 01 - Address: 00:23:F8:AD:40:0E
ESSID:"Northeast"
Mode:Managed
Channel:6
Quality:100/100 Signal level:-29 dBm Noise level:-81 dBm
Encryption key:on
Bit Rates:18 Mb/s
In this case, we see that our wireless interface is ra0, and the access point is "Northeast" with encryption (WEP access point).
Bring up the wireless interface:
$ sudo ifconfig ra0 up
Bind the access point to the wireless interface with key being initialized. (If your access point is not encrypted, omit "key open".)
$ sudo iwconfig ra0 essid "Northeast" key open
Set our WEP key "77022" (you should know it somehow!). (If your access point is not encrypted, skip this step.)
$ sudo iwconfig ra0 essid "Northeast" key s:77022
Get an IP address from the access point:
$ sudo dhclient ra0
Now, we joined the wireless network!