Monday, June 4, 2012

Using WiFi just from Linux Terminal

Are you tired of Network Managers that try to reduce pain regarding Wireless connections and end up with unstable or never-connecting Wireless problems? Then, command line comes to the rescue and `wpa_supplicant` as our weapon. Throughout the tutorial, I will be using these random access point details with WPA-PSK:
SSID: linuxdo
Passphrase: myphrase
And, `wlan0` is the wireless interface. Find the one corresponding in your system using `iwconfig`.
Install `wpa_supplicant` for your distro if not installed.
For CentOS/RedHat and other Yum based systems:
# yum install wpa_supplicant

For Debian based systems including Ubuntu:
# apt-get update && apt-get install wpa_supplicant
Now, we need to create the configuration file for `wpa_supplicant`. There is an easy way out using:
# wpa_passphrase linuxdo myphrase >/root/linuxdo.conf
It's the time to connect now. Run `wpa_supplicant` as:
# wpa_supplicant -iwlan0 -c/root/linuxdo.conf
After you get `CTRL-EVENT-CONNECTED`, you should run `dhclient` as:
# dhclient wlan0
This way, you will get a dynamic IP from the router.
Test your internet connection by opening a web browser and loading `linuxdo.blogspot.com`. You will get it.
Since, we are now familiar with `wpa_supplicant` now, disable Wireless in NetworkManager interface to avoid conflicts.