Wireless Tools

Unwired


Sunshine, pool, laptop, an open WLAN, and Wireless Tools were all it took for Heike to submit the latest issue of "Command Line" from Crete.

By Heike Jurzik

www.sxc.hu

Wireless Tools [1] is a collection of command-line programs that not only serve up information on WLANs but also help you configure wireless connections.

The Tools

The tool set includes the following:

The Suite

Likely, you will find this collection of programs in your distribution's repository in the wireless-tools package; computers with a WLAN interface will typically have the package pre-installed.

With some distributions, the Wireless Tools suite additionally includes the ifrename program. Debian users can install the tool from a package of the same name. To use the pre-installed programs, you must install and load the drivers for your WLAN card.

iwconfig

iwconfig works like ifconfig: Called without any additional parameters, it will give you a whole bunch of information about your network interfaces in a terminal window.

Figure 1 shows the output on a laptop, with lo as the loopback interface, eth1 as a normal network card, and eth0 as a WLAN interface.

Figure 1: If you need to query and change WLAN parameters, iwconfig can help.

A connection to a network called cretablue has been established; the WLAN card's name is Broadcom 4318. The access point for the cretablue network tells you its MAC address and that it is running in managed mode.

If you prefer not to see the information for the other interfaces, pass the name of the interface you are interested in to iwconfig, for example:

/sbin/iwconfig eth0

The system administrator root can run the command without specifying the path because it resides in /sbin, which is in root's path.


ifconfig: One of the most important network configuration tools. When called without any additional parameters, ifconfig will show you the currently configured network interfaces. Most distributions store the program in the /sbin directory so that normal users will need to specify the full path, /sbin/ifconfig. Administrators can use ifconfig to set up network cards in the shell.

Setting Up an Interface

Besides the network interface name, iwconfig supports other command-line options, which follow the command shown previously. The following commands change an existing configuration and require root privileges. To associate with another network, you must specify the ESSID, which follows the iwconfig command and the interface name:

iwconfig eth0 essid "Beach Cafe"

If the network name includes blanks or special characters, you need to place it in double quotes. If the network uses a WEP key, you can use the key option to specify it. To do so, either enter the key in hexadecimal notation or type s: followed by the WEP password:

iwconfig eth0 essid "Beach Cafe" key s:IceCreamRocks

If needed, you can also define the channel you are using (channel 11), specify the mode (e.g., mode Managed or mode Ad-Hoc, and so on), specify the nickname you will use on the network (e.g., nick "External Cisco Card"), and many other things. The man page for iwconfig has a full list. Don't forget to configure the IP address for your card. Most public networks will support automatic IP address assignments via DHCP; root can use the dhclient program for this. If needed, you can pass an interface name in to this tool (Listing 1).

Listing 1: dhclient
01 # dhclient eth0
02 ...
03 DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 8
04 DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 19
05 DHCPOFFER from 192.168.1.254
06 DHCPREQUEST on eth0 to 255.255.255.255 port 67
07 DHCPACK from 192.168.1.254
08 bound to 192.168.1.72 -- renewal in 38488 seconds.


ESSID: Extended Service Set Identifier. A unique identifier for an IEEE 802.11 wireless network with a maximum of 32 digits. The ESSID disambiguates multiple wireless networks at the same place.

Tracker

iwlist is another handy tool; you can use the scanning option to look for available wireless networks (Listing 2).

Listing 2: iwlist Scanning Option
01 # iwlist scanning
02 eth0 Scan completed :
03         Cell 01 - Address: 00:14:6C:91:77:EC
04                   ESSID:"Poolbar upstairs"
05                   Protocol:IEEE 802.11bg
06                   Mode:Master
07                   Channel:6
08                   Encryption key:off
09                   Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 9 Mb/s; 11 Mb/s
10                             6 Mb/s; 12 Mb/s; 18 Mb/s; 24 Mb/s; 36 Mb/s
11                             48 Mb/s; 54 Mb/s
12                   Quality=100/100  Signal level=-217 dBm
13                   Extra: Last beacon: 884ms ago
14         Cell 02 - Address: 02:20:A6:B7:04:41
15                   ESSID:"STAR_BEACH"
16                   Protocol:IEEE 802.11bg
17                   Mode:Master
18                   Channel:11
19                   Encryption key:off
20                   Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 22 Mb/s
21                   Quality=100/100  Signal level=-145 dBm
22                   Extra: Last beacon: 232ms ago

If you are more interested in the frequencies and channels your WLAN card supports, type the frequency option. Other parameters include the supported bit rates (iwlist bit rate), encryption mechanisms (iwlist encryption), or the transmitter power (iwlist power).

iwgetid is a kind of lightweight iwconfig. By default, it gives you a single line that tells you which interface is associated with which (E)SSID:

# iwgetid
ath0     ESSID:"cretablue"

iwgetid is thus perfect for scripting.

Various options will tell the program to display other details. For example, --ap gives you the access point MAC address, --freq shows the frequency, --channel gives you the channel, and so on.

Listening In

iwevent gives you a kind of logfile for wireless events and monitors activity on the wireless network by default (see Listing 3).

To stop listening, press Ctrl+C. If you need information on other WLAN users in the same radio cell, you can use iwspy. To do so, first ping the IP addresses,

$ ping 192.168.1.100
PING 192.168.1.100
(192.168.1.10
0) 56(84) bytes of data.
64 bytes from
192.168.1.100: icm
p_seq=1 ttl=64 time=6.23
ms
...

then pass in your own interface and the IP address of the remote computer:

iwspy ath0 192.168.1.100

iwspy then gives you details about the connection quality, signal strength, the MAC address of the other client, and so on (Listing 4).

Listing 3: iwevent
01 # iwevent
02 Waiting for Wireless Events from interfaces...
03 16:36:21.690798   ath0     Scan request completed
04 16:39:51.557551   ath0     Set ESSID:"STAR_BEACH"
05 16:40:01.063199   ath0     Set ESSID:"cretablue"
06 16:40:01.063238   ath0     New Access Point/Cell address:Not-Associated
07 16:40:01.456160   ath0     Scan request completed
08 16:40:01.839243   ath0     Scan request completed
09 16:40:02.184058   ath0     Scan request completed
10 16:40:02.184107   ath0     Custom driver event:associating failed because no suitable network was found
11 ...
Listing 4: iwspy
01 # iwspy ath0
02 ath0      Statistics collected:
03     00:C0:A8:D4:6F:EC : Quality:2  Signal level:0  Noise level:3
04     Link/Cell/AP      : Quality=30/94  Signal level=-64 dBm  Noise level=-94 dBm
05     Typical/Reference : Quality:0  Signal level:0  Noise level:0

All Inclusive

As you can see, you don't need a complicated GUI tool to set up your network configuration and send a document from Greece to the office back home - the Wireless Tools suite gives command-line fans everything they might need on vacation.

After finding the best network in the vicinity and establishing a connection, the programs even let you keep a close eye on your fellow vacationers.

INFO
[1] Wireless Tools: http://www.hpl.hp.com/personal/Jean_Tourrilhes/Linux/Tools.html