Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

This question already has an answer here:

I would like to use my wifi doggle in my pc (ubuntu 12.04). I am able to connect to my access point through the GUI. I would like to do the same in the terminal.

My access point uses WEP. So I typed the following commands

iwconfig wlan0 mode managed key 6d6f6e6579
iwconfig wlan0 essid "AccessPoint"
dhclient wlan0

after typing dhclient wlan0 it waits like 1-2 min then outputs nothing and cannot connect to the Access Point.

iwconfig output:

wlan0 IEEE 802.11bgn ESSID:"AccessPoint"
      Mode:Managed Access Point: Not-Associated Tx-Power=20 dBm
      Retry long timit:7 RTS thr=2347 B Fragment thr:off
      Encryption key:6D6F-6E65-79
      Power Management:off

I would appreciate any suggestion

share|improve this question
add comment

marked as duplicate by Luis Alvarado Jul 10 '13 at 0:41

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3 Answers

You can't get IP from DHCP Server.. probably you have wrong parameters in your iwconfig command or its not complete! Im going to make a comprehensive troubleshoot for you however some of them would be unrelated to your case! First of all lets check if there's other services using your wireless card.. you can try unblocking radio frequencies with this command:

sudo rfkill unblock wifi

after that check block status :

sudo rfkill list

if there's any "yes" beyond Wireless LAN , it means something preventing rfkill to unblock your wifi; you should find that service and stop it. $ sudo service {service} stop generally,they are other network tools.especially network managers. stop them or uninstall.

after that set iwconfig parameters in a proper way..to see wifi access points and their specifications:

sudo iwlist scanning

check those parameters and fill (use root privilege sudo or su root) : note : the wifi interface name could be different in your machine (eth# or wlan#)

iwconfig wlan0 essid {name of access point}
iwconfig wlan0 ap {access point mac address}

or if you don't know the MAC Address of access point :

iwconfig wlan0 ap any

and :

iwconfig wlan0 enc {on/off/restricted}
iwconfig wlan0 key s:{password}

at last pull up connection :

sudo ifconfig wlan0 up

now request for an IP :

sudo dhclient wlan0

check if your connection succeed (there should be an IP4) :

sudo ifconfig wlan0

or ping your gateway (route) ..Good luck

share|improve this answer
add comment

The iwconfig tool is like ifconfig and ethtool for wireless cards. You can view and set the basic Wi-Fi network details, such as the SSID, channel, and encryption. There's also many advanced settings you can view and change, including receive sensitivity, RTS/CTS, fragmentation, and retries.

For a comprehensive list of iwconfig usage please visit This site

Note: To connect your Linux machine to a WLAN using WPA, WPA2 or 802.1X you will need to use WPA Supplicant

Also Ubuntu has a good document, that talks about WiFi How To

share|improve this answer
    
Thank you for your suggestion, I already read that webpage before posting here. –  johan elmander Jun 11 '12 at 13:33
add comment

To connect to wireless networks from the command line, the easiest thing to do is to use the nmcli tool provided by the network-manager package.

To see available network connections:

nmcli con list

To connect to one of the connections in that list:

nmcli con up <connectionname>

You can do a lot more with nmcli as well - check the manpage on your system or online here: http://manpages.ubuntu.com/manpages/precise/man1/nmcli.1.html

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.