Monday, July 20, 2009

Wifi Configuration in redhat/suse linux



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.

Step1: When your run the command "iwconfig" you get the following output


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



Step2: Alternatively, you can run the command with an interface name like the following:

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

Step3

Localhost:~ # iwconfig mode

For example

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

Step4

localhost:~ # iwconfig essid

For instance,

localhost:~ # iwconfig wlan0 essid “ABC-WIFI”

Set Wireless Key (WEP)

We can set the WEP Encryption key (64bit or 128 bit)

Step5

localhost:~ # iwconfig key

For example,

localhost :~ # iwconfig wlan0 key 1234-5678-9101-1213

To disable WEP key

localhost :~ # iwconfig wlan0 key off

or to connect to an open network

localhost :~ # iwconfig wlan0 key open

Setting Channel which the interface uses

localhost:~ # iwconfig wlan0 channel

For example,

localhost:~ # iwconfig wlan0 channel auto

or

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

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

localhost:~ #ig wlan0 mode managed
lo
calhost :~ # iwconfig wlan0 essid “ABC-WIFI”
localhost:~ #
iwconfig wlan0 key 1111-2222-3333-4444
localhost:~ # 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


Hack Wireless WEP Network

1 comment:

  1. I would like to know the ways in which WEP security could be cracked. Kindly update the procedure in your next blog.

    -- Thomas

    ReplyDelete