SUSE & openSUSE

Tips,Tricks, Tutorials,How Tos and Troubleshooting suse linux

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 example

opensuse11:~ # 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

or

opensuse11:~ # 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.

9 Responses to “iwconfig – Wireless Interface configuration utility in Linux”

  1. Mark Halstead Says:

    What is the proper way to save these settings for next boot?

  2. Lucid Tips » Wireless using W200 on openSUSE 11.0 Says:

    [...] susegeek has a good post on using iwconfig to configure wireless. [...]

  3. Intel 4965 - Can 'see' the router but connection times out - openSUSE Forums Says:

    [...] 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 [...]

  4. alex Says:

    i follow these steps in configuring wlan0.but still i cannot connect to the internet.where can i see the wireless icons in opensuse 11.2?

  5. shashank Says:

    wonderful… i have been trying to connect to wifi in home from last 4 days but to no avail,
    even the service provider’s men didnt knew how to do it… but now its working..
    hats off.. :)

  6. Linux: Configurazione manuale di un access point | Pcc8 Technology Says:

    [...] 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 [...]

  7. Tomm Says:

    Hi, I did try same setting to SUSE Linux Enterprise Server 11 (i586).
    but it never assigned IP address by home rooter
    after following 4 steps.

    iwconfig wlan0 mode managed
    iwconfig wlan0 essid “ABC-WIFI”
    iwconfig wlan0 key 1111-2222-3333-4444
    iwconfig wlan0 channel auto

    Enterprise Suse wireless setting procedure is same as Open Suse,I supposed

    please give me advise.

  8. Tomm Says:

    sorry,
    IP is assigned as bellow but can not communicate,
    why ?


    wlan0 Link encap:Ethernet HWaddr 00:0A:79:39:F2:DB
    inet addr:192.168.1.17 Bcast:192.168.1.255 Mask:255.255.255.0
    UP BROADCAST RUNNING MULTICAST MTU:1492 Metric:1
    RX packets:107 errors:0 dropped:0 overruns:0 frame:0
    TX packets:98 errors:0 dropped:0 overruns:0 carrier:0
    collisions:0 txqueuelen:1000
    RX bytes:34406 (33.5 Kb) TX bytes:33798 (33.0 Kb)


    fmv-biblo:~ # ping yahoo.co.jp
    ping: unknown host yahoo.co.jp

  9. bilal Says:

    @Tomm

    its probably cause route table problem. imean default gateway adress.
    so try to ping this;

    ping 8.8.8.8

    if you take good response add default gateway
    i assume your router addr: 192.168.1.1 and iw device:wlan0
    so;
    fmv-biblo:~ # route add default gw 192.168.1.1 dev wlan0

    and

    ping google.com

    sory my english

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>