Sie sind auf Seite 1von 9

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? Phoenix Coffee offers free wireless access without an access key and they broadc ast their ESSID. 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:"bestcoffee" 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 "bestcoffee" 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 "bestcoffee" $ 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 Posted in Ubuntu, Unix. By matt June 13, 2008 Comments Disqus Like Dislike 12 people liked this. Login Add New Comment

Post as Image Showing 31 comments Savage How to connect to a wireless network from the Ubuntu command line using a WPA/WP A2 Personal key. For this to work.. you need to have WPA-Supplicant installed ... Ubuntu comes wi th WPA-Supplicant installed by default. if not present, install it using this command: sudo apt-get install wpasupplican t Ubuntu doesn't use a root password by default ...so we need to use the sudo comm and here. Now we need to create 2 files: wireless-wpa.sh + wireless-wpa.conf using the vi command. For those who are not familiar with vi , I will guide you through this. OK ..lets start: first we gonna create the wireless-wpa.sh type: sudo vi wireless-wpa.sh press the "i" button ones and insert text below. #!/bin/sh iface=eth1 #shut down interface ifconfig $iface down #set ad-hoc/management of wireless device iwconfig $iface mode Managed #enable interface ifconfig $iface up #stop any persistent wireless wpa2 sessions killall wpa_supplicant #apply WPA/WPA2 personal settings to device wpa_supplicant -B -Dwext -i $iface -c ./wireless-wpa.conf -dd

#obtain an IP address dhclient $iface Now we need to save this file and quit vi.... press "esc" button ones ... then t ype.. :wq ( you need to type the : also ) Thats done ... now we gonna make the wireless-wpa.conf type: sudo vi wireless-wpa.conf press the "i" button ones and insert text below. # config file using WPA/WPA2-PSK Personal key. ctrl_interface=/var/run/wpa_supplicant network={ ssid="my_router_id" scan_ssid=1 key_mgmt=WPA-PSK psk="1234567890" } Now we need to save this file and quit vi.... press "esc" button ones ... then t ype.. :wq ( you need to type the : also ) That's also done ... now we need to set the permissions for these 2 files. sudo chmod 755 wireless-wpa.sh sudo chmod 644 wireless-wpa.conf Make sure you put these 2 files in the same directory anywhere you like...else i t will not work. Run the following command to make a connection to your wireless Router/Accespoin t/ sudo ./wireless-wpa.sh That's all .... have fun! Like Reply 1 year ago 8 Likes Matt Wilson Thanks so much for putting this together! Like Reply 1 year ago in reply to Savage 2 Likes Asbestos Lawyer Thank you for this blog post. The commenter, then, becomes the critic who shapes the writer's next content. So I want to encourage you to keep on blogging in th e same style as you writing style is really perfect. _________________________ SEO Armenia Like Reply 1 year ago 1 Like Benjamin W. Smith DUDE, can you help me [hack a gibson](http://www.imdb.com/title/tt01... I need t his garbage file... Seems like you're one of those keyboard cowboy types I hear so much about!

Like Reply 3 years ago 2 Likes inkhorn Hi there, I was very interested to test out your tutorial on my home laptop that connects to my wireless router. My router requires that you enter in a long numerical wep key. I typed in the following: sudo iwlist wlan0 scan (it found the ESSID for my wireless router. That was nice ) sudo iwconfig wlan0 essid "myssid" key 12345678912345678912345 (obviously not my key. When I typed this in it gave me no complaints) sudo dhclient wlan0 The dhclient command started looking for DHCPs using the netmask 255.255.255.255 and port 67. I thought this was weird so I tried to tell dhclient to look for a dhcp using my normal netmask 255.255.255.0. I typed in 'sudo dhclient -s 255.25 5.255.0'. It still wouldn't work! I also tried setting up iwconfig to translate my numeric key into hex by typing in 'sudo iwconfig wlan0 key s:12345678912345678912345' after telling it my SSID. That still didn't work. Oh well, maybe some day i'll get wireless working from the command line without too much hassle! Like Reply 2 years ago 1 Like escape Thanks man... it really helped... Like Reply 3 years ago 1 Like Corey Haines Geek Like Reply 3 years ago 1 Like fixt Now that was perfect - There are so many who are good with linux but cannot comm unicate - Thankfully, it's not you. Please write a linux basics book. It will se ll. Very well. Like Reply 1 month ago Matt Wilson Thanks so much! Like Reply 1 month ago in reply to fixt Anon11869 Aaahhh... hacking with a cup of coffee, this is life! Haha good blog post, easy

to read and straightforward.. Thanks for posting it Like Reply 1 month ago Matt Wilson My pleasure! I hope it helped you out. Like Reply 1 month ago in reply to Anon11869 victorianixon Excellent writing about a wireless network..It is actually useful for me. keep w riting and happy blogging. Wireless network point to point Like Reply 5 months ago Matt Wilson Thanks! Like Reply 5 months ago in reply to victorianixon Mike Goodison Another Linux Noob here - just wanted to say what I've found here has been very helpful. Thanks Mike G Like Reply 5 months ago Matt Wilson Wonderful! Glad it helped. Like Reply 5 months ago in reply to Mike Goodison Karel Thank you!!! this helped me a lot. Like Reply 5 months ago Matt Wilson happy to help! Like Reply 5 months ago in reply to Karel Savage Very good article mate ! For those who can't get it to work ... remember to set your wireless card to the correct channel on wich the accespoint is running at.

iwconfig wlan0 channel 6 (example) Like Reply 1 year ago Matt Wilson Thanks for the tip! Like Reply 1 year ago in reply to Savage 1 Like Savage Hi Matt ... do you still need some tips for handling WPA-PSK connections ? Like Reply 1 year ago in reply to Matt Wilson Matt Wilson Absolutely. Like Reply 1 year ago in reply to Savage remove Palladium Antivirus Your article is really helpful! Like Reply 1 year ago Fernando Cool! Thanks a lot! Like Reply 2 years ago andrew how do i connect to a point if it dosnt have an essid i can connect to it in win dows but ubuntu wont connect without a essid but it still picksit up in a servey Like Reply 3 years ago andreas aargh, Ive got the same problem.. Installed Ubuntu Server edition 8.10 using no gui, and cant connect to the wireless network. I have tried the things explained over, and get the same results.. If you find it out, please tell :) Like Reply 3 years ago Matt Wilson Hi Andreas, use sudo iwlist eth1 scan to find out if your wireless card can see the network. Then use sudo iwconfig eth1 to see what your card's essid and key settings are, then set them. Some bad news -- I haven't been able to connect to a WPA2-authenticated wireless network yet.

Good luck! Like Reply 3 years ago in reply to andreas 1 Like ambreen i am trying to connect to my wireless network using the command line. the steps that are followed by me are given bellow current status : connected to the wlan0 with ESSID "mydesk" (where mydesk is the name of the network that i am connected to) use the commands #ifconfig wlan0 down ///////make the wlan0 interface down, now a this stage i am disconnected from any network available #ifconfig wlan0 uo ///////make the wlan0 interface up now my interface is up, but i am not connected to any netwrok, there are many wi reless lans available and i want to connect to a particular one wireless lan usi ng the console, so i use the following command #iwconfig wlan0 essid "mydesk" (where mydesk is the name of the network that i want to connected to) now at this stage i expect my interface to connect to the wireless lan with the ESSID "mydesk", but it is not the case, my browser still shows "no network conne ction" can you please guide me how can i connect to a particular wireless network using the command prompt only. i have used the dhclient wlan0 command as well and it gives the following output . [asheikh ~]# ifconfig wlan0 down [asheikh ~]# ifconfig wlan0 up [asheikh ~]# iwconfig wlan0 essid "default" [asheikh ~]# dhclient wlan0 PING 192.168.1.1 (192.168.1.1) from 192.168.1.37 wlan0: 56(84) bytes of data. --- 192.168.1.1 ping statistics --4 packets transmitted, 0 received, +3 errors, 100% packet loss, time 3001ms pipe 3 after a while performing the same sequence of steps it gives the following resul t [saheikh ~]# ifconfig wlan0 down [asheikh ~]# ifconfig wlan0 up [asheikh ~]# iwconfig wlan0 essid any [asheikh ~]# dhclient wlan0 dhclient(8834) is already running - exiting. This version of ISC DHCP is based on the release available on ftp.isc.org. Features have been added and other changes have been made to the base software release in order to make it work better with this distribution.

Please report for this software via the Red Hat Bugzilla site: http://bugzilla.redhat.com exiting. i hope i have explained my problem well any help will be appreciates. Like Reply 3 years ago dazed how about using wlan0 instead of wlano Like Reply 2 years ago in reply to ambreen Matt Wilson Hi -- I think that you'll get better feedback if you post your problem to some mailing lists. Also, after you run ifconfig wlan0 up, run iwconfig wlan0 to see what ESSID you are pointing at. Good luck! Like Reply 3 years ago in reply to ambreen J* Word, just switched to xmonad.. which rocks btw, and totally needed this, thx!! Like Reply 3 years ago Glen When penguins take over the world, you will be their king...thanks! Like Reply 3 years ago M Subscribe by email S RSS close Reblog this comment Powered by Disqus Learn more blog comments powered by DISQUS SUBSCRIBESite RSS feed About t+1 My name is Matt Wilson. I live in Cleveland Heights with my wife and sons. Most recently, I founded and built OnShift.com, a real-time staffing management tool for large health care facilities. Now I ve handed the keys to that project over to a very capable team of developers and I m searching for [...]more ? Recent Posts First episode of the next season of Mad Men plot summary Today is day two of the Strong Lifts program This is the nerdiest and awesomest thing you will read today How I like to work Happy Birthday to Nick!! Undo a fast-forward git merge The gauntlet software pattern

Categories Archives Meta Log in Entries RSS Comments RSS WordPress.org Tags mlp Proudly powered by WordPress and Carrington. Carrington Theme by Crowd Favorite

Das könnte Ihnen auch gefallen