Configuring Wireless Networking on a Linux PC

By Emmett Dulaney

On your Linux laptop, the PCMCIA or PC Card manager recognizes the wireless network card and loads the appropriate driver for the card. Linux treats the wireless network card like another Ethernet device and assigns it a device name such as eth0 or eth1. If you already have an Ethernet card in the laptop, that card gets the eth0 device name, and the wireless PC Card becomes the eth1 device.

You do have to configure certain parameters to enable the wireless network card to communicate with the wireless access point. You have to specify the wireless network name assigned to the access point, for example, and the encryption settings must match those on the access point. Usually, you can configure everything by using a graphical network-configuration tool that’s available for your Linux distribution. Just select the appropriate wireless network option and then walk through the configuration dialog boxes.

Linux wireless configuration
Configuration information for a new wireless connection.

The network-configuration tool saves your wireless network settings in a text file. The name of the text file depends on the wireless network device’s name. If the wireless network device’s name is eth0, the configuration is stored in the text file /etc/sysconfig/network-scripts/ifcfg-eth0. If the wireless device name is eth1, the file is /etc/sysconfig/network-scripts/ifcfg-eth1. This configuration file contains various settings for the wireless network card. The table below explains the meaning of the settings. Here is a slightly edited version of the /etc/sysconfig/network-scripts/ifcfg-eth1 file from a Linux laptop PC:

IPV6INIT=no
USERCTL=no
PEERDNS=yes
TYPE=Wireless
DEVICE=eth1
HWADDR=00:02:2d:8c:f9:c4
BOOTPROTO=dhcp
ONBOOT=no
DHCP_HOSTNAME=
NAME=
ESSID='HOME'
CHANNEL=6
MODE=Managed
RATE=auto
Settings in Configuration File for a Wireless Ethernet Network Interface
Parameter Meaning
BOOTPROTO The name of the protocol to use to get the IP address for the interface. The protocol used is dhcp or bootp for an Ethernet interface.
CHANNEL Channel number (between 1 and 14 in the United States and Canada), which must be the same as that set for the wireless access point. In managed mode, you don’t need to specify the channel.
DEVICE The device name for the wireless Ethernet network interface (eth0 for the first interface, eth1 for the second, and so on).
ESSID Extended Service Set (ESS) Identifier (ID), also known as the wireless network name. The name is case-sensitive and must be the same as the name specified for the wireless access point. Provide the name within single quotes (for example, 'HOME').
HWADDR The hardware address (also called the MAC address) of the wireless network card (six pairs of colon-separated hexadecimal numbers, such as 00:02:2d:8c:f9:c4). The wireless card’s device driver automatically detects this address.
IPV6INIT When set to yes, initializes IPv6 configuration for the wireless interface. Set it to no if you’re not using IPv6.
MODE The mode of operation of the wireless network card. Set it to Managed for a typical network that connects through a wireless access point.
NAME A nickname for your wireless network. If you don’t specify it, the host name is used as the nickname.
ONBOOT Set to yes to activate the wireless interface at boot time; otherwise, set to no.
PEERDNS Set to yes to enable the interface to modify your system’s /etc/resolv.conf file to use the DNS servers obtained from the DHCP server (the same server that provides the IP address for the interface). If you set this parameter to no, the /etc/resolv.conf file is left unchanged.
RATE Bit rate for the wireless connection, set to one of the following options: 1M, 2M, 5.5M, 11M, or auto. M means Mbps, or a million bits per second. Set it to auto to use the maximum possible transmission rate.
TYPE Set to Wireless for a wireless network interface.
USERCTL When set to yes, a user who isn’t logged in as root can control the device. Set it to no so that only root can control the device.

In some Linux distributions, the encryption key is stored separately. For a wireless Ethernet card whose device name is eth1, the encryption key is stored in the /etc/sysconfig/network-scripts/keys-eth1 file. Here is what this file contains for this example:

KEY=1fdf3fdefe

The key has 10 hexadecimal digits for a 40-bit key (such as 1fdf-3fde-fe) or 26 hexadecimal digits for a 104-bit key. The keys are 64-bit and 128-bit, respectively, but the encryption algorithm automatically generates 24 bits of the key, so you need to specify only the remaining bits. The longer the key is, the more secure the encryption is.

If you ever manually edit the parameters in the wireless Ethernet configuration file, type the following command to reactivate the wireless network interface after editing the configuration file:

/etc/init.d/network restart

In SUSE Linux, use YaST to configure the wireless network. SUSE stores the wireless configuration parameters in a file whose name begins with ifcfg-wlan, followed by a number such as 0 or 1, depending on the sequence number of the wireless network interface.

The configuration file is stored in the /etc/sysconfig/network directory. Here’s a typical list of wireless configuration parameters from a configuration file in SUSE Linux:

WIRELESS_MODE'Managed'
WIRELESS_ESSID='HOME'
WIRELESS_NICK''
WIRELESS_RATE='auto'
WIRELESS_AUTH_MODE='open'
WIRELESS_KEY_0='0123-4567-89'

To check the status of the wireless network interface, type the following command:

iwconfig

Here’s typical output from a laptop with a wireless Ethernet PC card. (The output should be similar in other Linux distributions.)

lo no wireless extensions.
eth0 no wireless extensions.
sit0 no wireless extensions.
eth1 IEEE 802.11b ESSID:"HOME" Nickname:"localhost.localdomain"
Mode:Managed Frequency:2.437 GHz Access Point: 00:30:AB:06:E2:5D
Bit Rate=11 Mb/s Sensitivity:1/3
Retry limit:4 RTS thr:off Fragment thr:off
Encryption key:1FDF-3FDE-FE Security mode:open
Power Management:off
Link Quality=51/92 Signal level=-40 dBm Noise level=-91 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:27
Tx excessive retries:0 Invalid misc:0 Missed beacon:0

Here, the eth1 interface refers to the wireless network card. The encryption key was edited and some other parameters to hide those details, but the sample output shows you what you’d typically see when the wireless link is working.