Saturday, May 8, 2010

How to connect to a wireless network from the Ubuntu command line

Why use a friendly GUI when there’s cryptic shell commands out there?

Here’s how I connect:


$ sudo iwlist eth1 scan # eth1 is my wireless card.
eth1 Scan completed :
Cell 01 - Address: 0A:1D:19:15:C2:C1
ESSID:"airborneaccess"
Mode:Master
Channel:5
Frequency:2.432 GHz (Channel 5)
Quality=88/100 Signal level=-44 dBm Noise level=-81 dBm
Encryption key:off
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
9 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s
48 Mb/s; 54 Mb/s
Extra:tsf=0000003befa89182



That scan lists every available access point. The important piece of information to extract here is the ESSID. Now I set my wireless card up to connect to that ESSID:


$ sudo iwconfig eth1 essid "ESSID of your acceesspoint"


And finally, I tell my card to request an IP address from the router:


$ sudo dhclient eth1 # gimme an IP address plz!
There is already a pid file /var/run/dhclient.pid with pid 6911
killed old client process, removed PID file
Internet Systems Consortium DHCP Client V3.0.6
Copyright 2004-2007 Internet Systems Consortium.
All rights reserved.
For info, please visit http://www.isc.org/sw/dhcp/

wmaster0: unknown hardware address type 801
wmaster0: unknown hardware address type 801
Listening on LPF/eth1/00:1c:bf:96:7e:21
Sending on LPF/eth1/00:1c:bf:96:7e:21
Sending on Socket/fallback
DHCPREQUEST of 192.168.1.112 on eth1 to 255.255.255.255 port 67
DHCPACK of 192.168.1.112 from 192.168.1.1
bound to 192.168.1.112 -- renewal in 251284 seconds.


I can type these three commands way faster than waiting for the GUI to fire up. Here they are again, without all the output:


$ sudo iwlist eth1 scan
$ sudo iwconfig eth1 essid "ESSID of your acceesspoint"
$ sudo dhclient eth1


Sometimes, I need to connect to a network with a hidden ESSID. That’s just as easy. I just configure the ethernet card to connect to anything:


$ sudo iwconfig eth1 essid any # any is a keyword, not the name of an ESSID.


Finally, some networks require an access key. Sometimes, people can give you the human-friendly version, and you can type that in like this:


$ sudo iwconfig eth1 key s:password # translates to the hex for me.


Note the s: in front. That translates what I type into the hex jibberish.

Other times, people insist on giving you the goofy string of hex digits, so you can set it like this:


$ sudo iwconfig eth1 key ACDB-1234-1234-EFG2

3 comments:

5cr1pt_k1d said...

Great bro. . you know some undergroundZ. .! thanks for tut. i need a help bro. . about wimax bm22 do you have a shared idea about port forwarding its seems it doesnt work? how can i contact you? and pls add me at facebook i will try to contact you there for port forwarding my wimax. .
i can pay. .P200 for success! heres my email at facebook
bl4ckl4b3l@yahoo.com

hope i could catch you up there! CHEERS! :)

Tech31 said...

sorry i dont have bm622. but if you might have bm622i or need to get the idea - try to break-in on the administrator (see here http://cyb3rc0n.blogspot.com/2011/04/huawei-bm622i-admin-password_8670.html?showComment=1315420575137#comment-c3751516424017915218)

once you have login on bm22i as admin, you can access the NAT menu, then you can set port-forward of your desired port/ip .

Tech31 said...

http://cyb3rc0n.blogspot.com/2011/04/huawei-bm622i-admin-password_8670.html?showComment=1315420575137#comment-c3751516424017915218