iwconfig - Wireless Interface configuration utility in Linux
Posted by admin on July 16th, 2008
Iwconfig like ifconfig is a Wireless interface configuration utility in Linux.It is used to set the parameters of the network interface which are specific to the wireless operation. Iwconfig may also be used to display the parameters and the wireless statistics. iwconfig extracts these information from /proc/net/wireless file.
In the simplest form, simply typing the command without any arguements displays the current status of all the Wireless interfaces on the system:
opensuse11:~ # iwconfig
lo no wireless extensions.wmaster0 no wireless extensions.
wlan0 IEEE 802.11abg ESSID:”xxxxxxxx”
Mode:Managed Frequency:2.437 GHz Access Point: 00:11:22:33:44:55
Bit Rate=54 Mb/s Tx-Power=15 dBm
Retry min limit:7 RTS thr:off Fragment thr=2352 B
Encryption key:xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx [2] Security mode:open
Power Management:off
Link Quality=96/100 Signal level:-32 dBm Noise level=-69 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
Alternatively, you can run the command with an interface name like the following:
opensuse11:~ # iwconfig wlan0
wlan0 IEEE 802.11abg ESSID:”xxxxxxxx”
Mode:Managed Frequency:2.437 GHz Access Point: 00:11:22:33:44:55
Bit Rate=54 Mb/s Tx-Power=15 dBm
Retry min limit:7 RTS thr:off Fragment thr=2352 B
Encryption key:xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx-xxxx [2] Security mode:open
Power Management:off
Link Quality=96/100 Signal level:-32 dBm Noise level=-69 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
Set operation Mode
The Wireless interface can be set to one of the following different modes which impacts how the device operates:
managed - Node is a client connecting to an Access Point
master - Node acts as an Acces point
secondary - Node acts as a Secondary to a master Access point
ad-hoc - Operates in a One to One Ad-hoc connection to another Wireless device
monitor - Doesn’t connect to any Wireless network but sits and listens on all the packets on a frequency
repeater - Forwards packets between wireless nodes
The mode can be set as follows:
opensuse11:~ # iwconfig <interface> mode <managed|master|secondary|ad-hoc|monitor|repeater|auto>
For exampleopensuse11:~ # iwconfig wlan0 mode managed
The above sets the interface wlan0 in managed mode.
Set ESSID for Network
Once, the mode is set, we can go ahead and set the essid of the network to which we connect
The ESSID can be set as
opensuse11:~ # iwconfig <interface> essid <ESSID>
For instance,
opensuse11:~ # iwconfig wlan0 essid “ABC-WIFI”
Set Wireless Key (WEP)
We can set the WEP Encryption key (64bit or 128 bit)
opensuse11:~ # iwconfig <interface> key <xxxx-xxxx-xxxx-xxxx>
For example,
opensuse11:~ # iwconfig wlan0 key 1234-5678-9101-1213
To disable WEP key
opensuse11:~ # iwconfig wlan0 key off
or to connect to an open network
opensuse11:~ # iwconfig wlan0 key open
Setting Channel which the interface uses
opensuse11:~ # iwconfig wlan0 channel <No.| auto>
For example,
opensuse11:~ # iwconfig wlan0 channel auto
oropensuse11:~ # iwconfig wlan0 channel 11
to use channel 11.
There are other options that can be set using the iwconfig command. This can be found from the help or man page
opensuse11:~ # iwconfig –help
Usage: iwconfig [interface]
interface essid {NNN|any|on|off}
interface mode {managed|ad-hoc|master|…}
interface freq N.NNN[k|M|G]
interface channel N
interface bit {N[k|M|G]|auto|fixed}
interface rate {N[k|M|G]|auto|fixed}
interface enc {NNNN-NNNN|off}
interface key {NNNN-NNNN|off}
interface power {period N|timeout N|saving N|off}
interface nickname NNN
interface nwid {NN|on|off}
interface ap {N|off|auto}
interface txpower {NmW|NdBm|off|auto}
interface sens N
interface retry {limit N|lifetime N}
interface rts {N|auto|fixed|off}
interface frag {N|auto|fixed|off}
interface modulation {11g|11a|CCK|OFDMg|…}
interface commit
Check man pages for more details.
Let’s use the above for instance to quickly connect to a Wireless network as follows
opensuse11:~ # iwconfig wlan0 mode managed
opensuse11:~ # iwconfig wlan0 essid “ABC-WIFI”
opensuse11:~ # iwconfig wlan0 key 1111-2222-3333-4444
opensuse11:~ # iwconfig wlan0 channel auto
The above sets the wlan0 interface to managed mode so it can connect to a Wireless Access point. We then configure an ESSID of a network and then a related key and an auto channel selection.
NOTE: using WEP security is not secure and can be cracked in in minutes. We’ll cover soon the use of WPA/WPA2 for stronger protection from hackers.
August 2nd, 2008 at 12:09 pm
What is the proper way to save these settings for next boot?
September 6th, 2008 at 8:53 am
[...] susegeek has a good post on using iwconfig to configure wireless. [...]
December 10th, 2008 at 12:28 pm
[...] might try to just bypass NetworkManager all together and just use iwconfig to set up the connect. iwconfig - Wireless Interface configuration utility in Linux | SUSE & openSUSE The idea is just to see if you can get it working at all, then play with the GUI more. But if you [...]