iwconfig
Desktop Apps Training - Wireless

Linux Desktop TutorialsThe tutorial you're about to read has been marked as one of our older tutorials. While it may still prove useful to you, we recommend visiting our more recent desktop tutorials section.

The iwconfig command will allow you to obtain information about your configuration and allow you to make modifications to the configuration.

In this example iwconfig looks at a number of network connections and determines which ones are to be used for wireless and which ones are not wireless as you can see.

 

iwconfig

lo no wireless extensions.

eth0 no wireless extensions.

irda0 no wireless extensions.

wmaster0 no wireless extensions.

As you look at wlan0 you can see that no ESSID is associated with this card and no Access Point is listed, which means that this connection will not work.

wlan0 IEEE 802.11abg ESSID:""

Mode:Managed Frequency:2.412 GHz Access Point: Not-Associated

Tx-Power=0 dBm

Retry min limit:7 RTS thr:off Fragment thr=2352 B

Encryption key:off

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

 

Now as you view ath0 you can see the ESSID is listed and the Access Point MAC address is listed indicating that this card will work. Note that as you examine the information closely you can see that it is a 11g card and the frequency is 2.437 GHz. You also see that Encryption is currently turned off. The Link Quality is also listed when you run the command.

 

ath0 IEEE 802.11g ESSID:"cydo" Nickname:""

Mode:Managed Frequency:2.437 GHz Access Point: 00:14:BF:7F:59:B2

Bit Rate:48 Mb/s Tx-Power:18 dBm Sensitivity=1/1

Retry:off RTS thr:off Fragment thr:off

Encryption key:off

Power Management:off

Link Quality=49/70 Signal level=-47 dBm Noise level=-96 dBm

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

Tx excessive retries:0 Invalid misc:0 Missed beacon:0

You can use many options with iwconfig as it is very flexible. When you use iwconfig be sure to use the correct connection with the command.

When you want to set your card so that it is able to be managed by the access point set the card to managed with this command:


iwconfig ath0 managed

If this is a peer to peer network with no access point set the card to the ad-hocx mode with this command

iwconfig ath0 mode ad-hoc

iwconfig [interface] mode monitor (set card to RFMON mode our favourite)

 

The essid or name of your local network can be added with this command:

iwconfig ath0 essid "cydo"

 

Here is the output:

 

ath0 IEEE 802.11g ESSID:"cydo" Nickname:""



If you have a 128 bit WEP key it can be set with this command:



iwconfig ath0 key 2222-2222-2222-2222



The output can be viewed here:



ath0 IEEE 802.11g ESSID:"cydo" Nickname:""

Mode:Managed Frequency:2.437 GHz Access Point: 00:14:BF:7F:59:B2

Bit Rate:48 Mb/s Tx-Power:18 dBm Sensitivity=1/1

Retry:off RTS thr:off Fragment thr:off

Encryption key:****-****-****-****[4] Security mode:op

Power Management:off

Link Quality=49/70 Signal level=-47 dBm Noise level=-96 dBm

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

Tx excessive retries:0 Invalid misc:0 Missed beacon:0





If you want to disable the key you can use this command:



iwconfig ath0 key off

 

You can set your card to open which will not use authentication with this command:



iwconfig ath0 key open

 

You can modify the channel that your card is using with this command:



iwconfig ath0 channel 11



You will be able to use channels 1-14, but of course make sure that the channel you choose is the same one as on the wireless access point.



If you want to automate the process you can use the auto option:



iwconfig ath0 channel auto





The frequency you are using can be set using this command:

 

iwconfig ath0 freq 2.437G

The iwconfig command is a powerful command that can get it all going for you but, if you want the settings to be permanent you will need to set them in the network interface files. If you are using Ubuntu or Debian check in /etc/network/interfaces and set it so it looks like this:



auto lo

iface lo inet loopback



auto ath0

iface ath0 inet dhcp

wireless-essid cydo



That will set up the lo or loopback and also set the ath0 interface with a dhcp address and the wireless essid of cydo. Note once again that the interface name may not be ath0 and certainly will not be cydo for the essid.