The following was removed from Chapter 14: “Connectivity”.
Configure a Wireless Network Interface
In the previous section, “View the Status of Your Wireless Network Interfaces,” you used
iwconfig to see important details about your wireless card and its connection. You can also use
iwconfig, however, to configure that wireless card and its connections. If this sounds like
ifconfig, it should, as
iwconfig was based on
ifconfig and its behaviors.
You can make several changes with
iwconfig, but you’re only going to look at a few (for more details, see
The network topologies associated with wired networks, such as star, bus, and ring, to name a few, have been known and understood for quite some time. Wireless networks introduce some new topologies to the mix, including the following:
- Managed (an access point creates a network to which wireless devices can connect; the most common topology for wireless networking)
- Ad-Hoc (two or more wireless devices form a network to work with each other)
- Master (the wireless device acts as an access point)
- Repeater (the wireless device forwards packets to other wireless devices)
There are others, but those are the main ones.
For more on stars, busses, rings, and the like, see Wikipedia’s “Network Topology” at http://en.wikipedia.org/wiki/Network_topology.
iwconfig, you can tell your wireless card that you want it to operate differently, in accordance with a new topology.
# iwconfig ath0 mode ad-hoc
After specifying the interface, simply use the mode option following the name of the mode you want to use (
ad-hoc in this case).
Remember that the card you’re using in these examples has an interface name of
ath0; yours might be
wlan0, or something else entirely. To find out your interface’s name, use
iwconfig by itself, as discussed in the previous section.
The Extended Service Set Identifier (ESSID) is the name of the wireless network to which you’re joined or you want to join. Most of the time an ESSID name of
any will work just fine, assuming that you can meet the network’s other needs, such as encryption, if that’s necessary. Some networks, however, require that you specify the exact ESSID.
# iwconfig ath0 essid lincoln
Here you are joining a wireless network with an ESSID of
lincoln. Simply use the
essid option, followed by the name of the ESSID, and you’re good.
More and more networks are using encryption to protect users’ communications from sniffers that capture all the traffic and then look through it for useful information. The simplest form of network encryption for wireless networks is Wired Equivalent Privacy (WEP). Although this provides a small measure of security, it’s just that: small. WEP is easily cracked by a knowledgeable attacker, and it has now been superseded by the much more robust Wi-Fi Protected Access (WPA). Unfortunately, getting WPA to work with wireless cards on Linux can be a real bear, and is beyond the scope of this book. Besides, WEP, despite its flaws, is still far more common, and it is better than nothing. Just don’t expect complete and total security using it.
For more on WEP and WPA, see Wikipedia’s “Wired Equivalent Privacy” (http://en.wikipedia.org/wiki/Wired_Equivalent_Privacy) and “Wi-Fi Protected Access” (http://en.wikipedia.org/wiki/Wi-Fi_Protected_Access). You can find information about getting WPA to work with your Linux distribution at “Linux WPA/WPA2/IEEE 802.1X Supplicant” (http://w1.fi/wpa_supplicant/). If you’re using Windows drivers via ndiswrapper, also be sure to check out “How to Use WPA with ndiswrapper” (http://sourceforge.net/apps/mediawiki/ndiswrapper/).
WEP works with a shared encryption key, a password that exists on both the wireless access point and your machine. The password can come in two forms: hex digits or plain text. It doesn’t really matter which because
iwconfig can handle both. If you’ve been given hex digits, simply follow the
enc option with the key.
# iwconfig ath0 enc 646c64586278742a6229742f4c
If you’ve instead been given plain text to use, you still use the
enc option, but you must preface the key with
s: to indicate that what follows is a text string.
# iwconfig ath0 enc s:dldXbxt*b)t/L
I created those WEP keys using the very nice WEP Key Generator found at http://www.andrewscompanies.com/tools/wep.asp.
If you have several options to change at one time, you probably would like to perform all of them with one command. To do so, follow
iwconfig with your device name, and then place any changes you want to make one after the other.
# iwconfig ath0 essid lincoln enc 646c64586278742a6229742f4c
The preceding listing changes the ESSID and sets WEP encryption using hex digits for the wireless device
ath0. You can set as many things at one time as you’d like.