46

I'm having trouble making my wireless connection work, and I realized I don't really know how to use the tools I have, in this case, the iwconfig command in Ubuntu-9.04. Here is what I get when I run iwconfig:

lo        no wireless extensions.

eth0      no wireless extensions.

wmaster0  no wireless extensions.

wlan0     IEEE 802.11bgn  ESSID:"Network"  
          Mode:Managed  Frequency:2.412 GHz  Access Point: Not-Associated   
          Tx-Power=20 dBm   
          Retry min limit:7   RTS thr:off   Fragment thr=2352 B   
          Power Management:off
          Link Quality:0  Signal level:0  Noise level:0
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

vboxnet0  no wireless extensions.

pan0      no wireless extensions.

"Network" is the name of my wireless network, by the way. But what does this all mean? How can this information help me acquire a working wireless connection?

When I try associating a key using

sudo iwconfig wlan0 key s:my_key

I get the following error message:

Error for wireless request "Set Encode" (8B2A) :
    SET failed on device wlan0 ; Invalid argument.

I do have the right key though, so what's the problem?

5
  • Are you using WEP, WPA or WPA2? If you are using WPA2, does your laptop hardware support it?
    – MDMarra
    Sep 30, 2009 at 15:44
  • 1
    I don't know what WEP, WPA and WPA2 are. I have tried them all though, and none of them work. As for my laptop's hardware supporting it, I know I have access to the wireless network at school. Beside the schools network as shown in "Wicd Manager", there is WPA2. But in the advanced settings, it says that it uses PEAP with TKIP. So I don't really understand what this means...
    – Shawn
    Oct 1, 2009 at 15:12
  • If you just want to get wifi working, use a network management utility such as wicd: sudo aptitude update && sudo aptitude install wicd.
    – deed02392
    Feb 27, 2012 at 10:55
  • 2
    deed02392 please don't bamboozle people with guis, this should be solved in the command line or not at all.
    – Owl
    Jan 10, 2020 at 10:34
  • for anyone who is trying to connect to wpa2 network linuxbabe.com/command-line/…
    – Aleks
    Mar 20, 2023 at 14:30

8 Answers 8

15

wlan0 IEEE 802.11bgn ESSID:""

Means your card supports 802.11 b/g/n standards and you are currently not connected to any network (ESSID, the name identifying network is empty)

Mode:Managed

Operating mode for the device. Depending on your card, you may select one of these:

  • Ad-Hoc (network composed of only one cell and without Access Point)
  • Managed (node connects to a network composed of many Access Points, with roaming)
  • Master (the node is the synchronisation master or acts as an Access Point)
  • Repeater (the node forwards packets between other wireless nodes)
  • Secondary (the node acts as a backup master/repeater)
  • Monitor (the node is not associated with any cell and passively monitor all packets on the frequency)
  • Auto.

Frequency:2.412 GHz

Or channel - same as you see in GUI tools to manage wireless cards - you may input either frequency or channel number

Access Point: Not-Associated

Gives you exact MAC address of AP you're connecting to. If you have multiple AP's in your network and you'd like to figure out to which AP you're connected.

Tx-Power=20 dBm

This is your card's transmit power - basically the higher, the more energy your card will require.

Retry min limit:7

This option describes retry behaviour of your card.

RTS thr:off

This describes whether your card checks for clear channel every time it sends a packet. This may improve performance in some cases.

Fragment thr=2352 B

This describes maximum packet size your card will send - basically if you have a noisy environment, the smaller the packets, the less probable is that your packet would have to be retransmitted, and if it would happen, the less data would have to be transmitted. According to manual, if this value is higher than maximum packet size, the card may send several packets together.

Power Management:off

This option gives information about power management your card use. You may choose to discard some packages (ie. bcast and mcast), set your card's activity cycles and some other options.

Link Quality:0 Signal level:0 Noise level:0

If your card is connected, this is where you'd be looking for link quality:) Signal level and noise level may be given dBm or any arbitrary unit.

Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0

Some statistics about errors during receiving: nwid means that probably there's another network in your neighbourhood using the same channel as yours, invalid crypto is a number of packet you card was unable to decrypt, invalid fragmentation means there were some packets missing.

Tx excessive retries:0

This is the number of packets your card was unable to deliver.

All above is based on iwconfig manual, you may find hml version here.

If you're going to configure your card using command line tools, be sure to turn networkmanager off and use Sathya's answer. If you have your key as a text, use

sudo iwconfig wlan0 key s:your_key

instead of

sudo iwconfig wlan0 key ABCD-1234-5678-EFG2
3
  • 12
    I tried both 'key s:my_key' and 'key my_key', but both fail. In the first case, I get -->'Error for wireless request "Set Encode" (8B2A) : SET failed on device wlan0 ; invalid argument.'<-- In the second case I get: -->'Error for wireless request "Set Encode" (8B2A) : invalid argument "my_key".'<-- of course, 'sudo dhclient wlan0' doesn't work either. The output finishes with -->'No DHCPOFFERS received.'<--
    – Shawn
    Sep 20, 2009 at 17:29
  • 4
    Misses the point that it's a WPA/WPA2 problem
    – LovesTha
    Apr 13, 2016 at 6:25
  • Voted down because the question was why does the iwconfig syntax give an error. You've given exactly the same syntax as the question without any example, what is "your_key" please provide an example.
    – Owl
    Jan 10, 2020 at 10:35
97

I'm surprised no one has bothered to mention this in the answers above but it sounds like you're really trying to get the wifi connection to work under linux -- not so much to understand each iwconfig parameters in all its gory details.

With this in mind it's crucially important to point out that iwconfig does not support WPA/WPA2 negotiation & authentication when connecting to a wlan network. That is to say the only wifi networks you can connect to with iwconfig are open unencrypted networks and WEP enabled networks.

Now the reason you're getting this strange error:

Error for wireless request "Set Encode" (8B2A) :
    SET failed on device wlan0 ; Invalid argument.

is because iwconfig is expecting a WEP-key for the key: parameter. Because of the way WEP works, this key has to meet one of these conditions:

  • ascii string that's exactly 5 characters in length
  • ascii string that's exactly 13 characters in length
  • hexidecimal string that's exactly 10 characters in length
  • hexidecimal string that's exactly 26 characters in length

Of course your key is 6 characters so this won't work and thus the error. Note that my_key technically, isn't a valid PSK either -- WPA/2 requires a minimum of 8 characters.

All this begs the question: so how do you connect to a WPA-TKIP/WPA2-AES enabled wlan? The answer is you have to use yet another program like wpa_supplicant. If you're not too crazy about the commandline method using a gui network manager like wicd manager will make this process much more seamless.

Any secure wifi network won't be using WEP since it's broken so it's important to realize iwconfig by itself can't connect to the more secure WPA/WPA2.

8
  • 11
    Wow, thanks! After a long while of Googling, this was a great help. Thanks!
    – loneboat
    Sep 13, 2012 at 3:11
  • 3
    +1. This is a vital piece of information, thanks for sharing.
    – DelboyJay
    Aug 25, 2016 at 13:33
  • 1
    Thank you soooo much! Been banging my head against iwconfig for an hour. Thanks! Dec 4, 2016 at 5:45
  • Sorry, but I also have to say it! Thank you for this. I just installed wicd after reading your answer and understanding what was going on, and I configured my wifi in 30 seconds.
    – april26
    Dec 26, 2016 at 3:41
  • "I'm surprised no one has bothered to mention... iwconfig does not support WPA/WPA2" - Neither does the iwconfig(8) man page. That's probably why so many people are wasting their time on it. It is a documentation bug.
    – jww
    Dec 8, 2019 at 15:54
17

Just edit /etc/network/interfaces and write:

auto wlan0
iface wlan0 inet dhcp 
                wpa-ssid <ssid>
                wpa-psk  <password>

After that write and close file and use command:

dhclient wlan0
3
  • 1
    Perfect on my little Raspberry Pi (wheezy) May 17, 2015 at 7:49
  • 3
    Thanks for this! dhclient was hanging on my laptop for some unknown reason but an ifup wlan0 got the ipaddress from the dhcp server and all was good after that.
    – DelboyJay
    Aug 25, 2016 at 13:30
  • 1
    That's fine if you have a WPA network, but if you have WEP that's not the solution. Nor does it answer the question why there is a syntax error in the iwconfig command when OP is doing everything right with the :s option
    – Owl
    Jan 10, 2020 at 10:45
1

For people with a "Set encode" problem, try what Carlanga user wrote in this blog.

sudo gedit /etc/network/interface

Clear everything and leave only:

auto lo
iface lo inet loopback

Then, restart.

2
  • 1
    arg ! its in spanish, so close but yet so far.
    – Sirex
    Jul 5, 2011 at 19:16
  • What?? That was magic!
    – smac89
    Jul 23, 2018 at 3:20
1

These are your network interfaces:

  • lo
  • eth0
  • wmaster0
  • wlan0 ( this interface is Wireless interface )
  • vboxnet0
  • pan0

The interface supports IEEE 802.11bgn.

ESSID:""  
Access Point: Not-Associated  

Indicates that the wireless interface is not connected to any wireless network.

To connect to a Wireless network, first type:

sudo iwlist wlan0 scan

This scans and lists all wireless networks which broadcast their ESSID. Assuming the ESSID is "Rox", then connect to the network.

sudo iwconfig wlan0 essid "Rox"

If the network requires a Key then, associate the key:

sudo iwconfig wlan0 key ABCD-1234-5678-EFG2

Finally, request for an IP:

sudo dhclient wlan0

You should be able to connect.

2
  • 2
    I tried both 'key s:my_key' and 'key my_key', but both fail. In the first case, I get -->'Error for wireless request "Set Encode" (8B2A) : SET failed on device wlan0 ; invalid argument.'<-- In the second case I get: -->'Error for wireless request "Set Encode" (8B2A) : invalid argument "my_key".'<-- of course, 'sudo dhclient wlan0' doesn't work either. The output finishes with -->'No DHCPOFFERS received.'<-- –
    – Shawn
    Sep 20, 2009 at 17:30
  • This question doesn't answer why there is a syntax error in the :s option. Which is what the question is about!!!
    – Owl
    Jan 10, 2020 at 10:46
0

iwconfig is identical to ifconfig, although it is for wireless devices installed on your machine. It can be used to set or display parameters, and show statistics. The wireless statistics are the same as you would find in /proc/net/wireless. Your output shows you currently have 1 functioning WLAN device, wlan0.

1
  • the file /proc/net/wireless is empty (when I open it in gedit, nothing is shown..) What does this mean?
    – Shawn
    Oct 1, 2009 at 15:14
0

Wow, for so long no has solved this problem still. If you're getting the error:

Error for wireless request "Set Encode" (8B2A) : SET failed on device wlan0 ; Invalid argument.

Instead of using "key" to include the WEP key, use "enc" instead.

iwconfig wlan0 essid "ESSID" enc "MY KEY"

.. then finish off with a

dhclient wlan0

1
  • "invalid argument". Again the same problem as ALL the answers here, HOW DO YOU GET THE KEY? HOW IS IT GENERATED?! Given a plaintext password, how do you get the key from that plaintext password. that's all this question is about.
    – Owl
    Jan 10, 2020 at 10:40
-1

Sorry dont see what you are doing with the s: try

sudo iwconfig wlan0 essid "name"
sudo iwconfig wlan0 key "key"
sudo ifup wlan0
sudo ifdown wlan0
2
  • Because the key is not HEX, it is ASCII, it requires the s: before it to work properly. Sep 29, 2013 at 4:25
  • @Danijel-James: except the s: option doesn't work. It gives you exactly the same error!!!!!!!!
    – Owl
    Jan 10, 2020 at 10:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .