Disclaimer :
This document is not valid and is not maintained anymore.
|
[ << ]
[ < ]
[ Home ]
[ > ]
[ >> ]
4. Wireless Networking
Content:
4.a. Introduction
Wireless networking on Linux is usually pretty straightforward. There are two
ways of configuring wifi: graphical clients, or the command line.
The easiest way is to use a graphical client once you've installed a desktop environment. Most graphical clients,
such as wicd and NetworkManager, are
pretty self-explanatory. They offer a handy point-and-click interface that gets
you on a network in just a few seconds.
Note:
wicd offers a command line utility in addition to the main
graphical interface. You can get it by emerging wicd with the
ncurses USE flag set. This wicd-curses utility is particularly
useful for folks who don't use a gtk-based desktop environment, but still want
an easy command line tool that doesn't require hand-editing configuration
files.
|
However, if you don't want to use a graphical client, then you can configure
wifi on the command line by editing a few configuration files. This takes a bit
more time to setup, but it also requires the fewest packages to download and
install. Since the graphical clients are mostly self-explanatory (with helpful
screenshots at their homepages), we'll focus on the command line alternatives.
You can setup wireless networking on the command line by installing
wireless-tools or wpa_supplicant. The important thing to remember
is that you configure wireless networks on a global basis and not an interface
basis.
wpa_supplicant is the best choice. For a list of supported drivers, read the wpa_supplicant
site.
wireless-tools supports nearly all cards and drivers, but it cannot
connect to WPA-only Access Points. If your networks only offer WEP encryption or
are completely open, you may prefer the simplicity of wireless-tools.
Warning:
The linux-wlan-ng driver is not supported by baselayout at this time.
This is because linux-wlan-ng have its own setup and configuration which
is completely different to everyone else's. The linux-wlan-ng developers
are rumoured to be changing their setup over to wireless-tools, so when
this happens you may use linux-wlan-ng with baselayout.
|
4.b. WPA Supplicant
WPA Supplicant is a
package that allows you to connect to WPA enabled access points.
Code Listing 2.1: Install wpa_supplicant |
# emerge net-wireless/wpa_supplicant
|
Important:
You have to have CONFIG_PACKET enabled in your kernel for
wpa_supplicant to work. Try running grep CONFIG_PACKET
/usr/src/linux/.config to see if you have it enabled in your kernel.
|
Note:
Depending on your USE flags, wpa_supplicant can install a graphical
interface written in Qt4, which will integrate nicely with KDE. To get it, run
echo "net-wireless/wpa_supplicant qt4" >> /etc/portage/package.use as
root before emerging wpa_supplicant.
|
Now we have to configure /etc/conf.d/net to so that we prefer
wpa_supplicant over wireless-tools (if both are installed,
wireless-tools is the default).
Code Listing 2.2: configure /etc/conf.d/net for wpa_supplicant |
modules="wpa_supplicant"
wpa_supplicant_eth0="-Dmadwifi"
|
Note:
If you're using the host-ap driver you will need to put the card in Managed
mode before it can be used with wpa_supplicant correctly. You can use
iwconfig_eth0="mode managed" to achieve this in
/etc/conf.d/net.
|
That was simple, wasn't it? However, we still have to configure
wpa_supplicant itself which is a bit more tricky depending on how secure
the Access Points are that you are trying to connect to. The below example is
taken and simplified from
/usr/share/doc/wpa_supplicant-<version>/wpa_supplicant.conf.gz
which ships with wpa_supplicant.
Code Listing 2.3: An example /etc/wpa_supplicant/wpa_supplicant.conf |
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=0
ap_scan=1
network={
ssid="simple"
psk="very secret passphrase"
priority=5
}
network={
ssid="second ssid"
scan_ssid=1
psk="very secret passphrase"
priority=2
}
network={
ssid="example"
proto=WPA
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP WEP104 WEP40
psk=06b4be19da289f475aa46a33cb793029d4ab3db7a23ee92382eb0106c72ac7bb
priority=2
}
network={
ssid="plaintext-test"
key_mgmt=NONE
}
network={
ssid="static-wep-test"
key_mgmt=NONE
wep_key0="abcde"
wep_key1=0102030405
wep_key2="1234567890123"
wep_tx_keyidx=0
priority=5
}
network={
ssid="static-wep-test2"
key_mgmt=NONE
wep_key0="abcde"
wep_key1=0102030405
wep_key2="1234567890123"
wep_tx_keyidx=0
priority=5
auth_alg=SHARED
}
network={
ssid="test adhoc"
mode=1
proto=WPA
key_mgmt=WPA-NONE
pairwise=NONE
group=TKIP
psk="secret passphrase"
}
|
4.c. Wireless Tools
Initial setup and Managed Mode
Wireless
Tools provide a generic way to configure basic wireless interfaces up to
the WEP security level. While WEP is a weak security method it's also the most
prevalent.
Wireless Tools configuration is controlled by a few main variables. The sample
configuration file below should describe all you need. One thing to bear in mind
is that no configuration means "connect to the strongest unencrypted Access
Point" - we will always try and connect you to something.
Code Listing 3.1: Install wireless-tools |
# emerge net-wireless/wireless-tools
|
Note:
Although you can store your wireless settings in
/etc/conf.d/wireless this guide recommends you store them in
/etc/conf.d/net.
|
Important:
You will need to consult the variable name documentation.
|
Code Listing 3.2: sample iwconfig setup in /etc/conf.d/net |
modules="iwconfig"
key_ESSID1="[1] s:yourkeyhere key [1] enc open"
key_ESSID2="[1] aaaa-bbbb-cccc-dd key [1] enc restricted"
preferred_aps="'ESSID1' 'ESSID2'"
|
Fine tune Access Point Selection
You can add some extra options to fine-tune your Access Point selection, but
these are not normally required.
You can decide whether we only connect to preferred Access Points or not. By
default if everything configured has failed and we can connect to an unencrypted
Access Point then we will. This can be controlled by the associate_order
variable. Here's a table of values and how they control this.
| Value |
Description |
| any |
Default behaviour |
| preferredonly |
We will only connect to visible APs in the preferred list |
| forcepreferred |
We will forceably connect to APs in the preferred order if they are not
found in a scan
|
| forcepreferredonly |
Do not scan for APs - instead just try to connect to each one in order
|
| forceany |
Same as forcepreferred + connect to any other available AP |
Finally we have some blacklist_aps and unique_ap selection.
blacklist_aps works in a similar way to preferred_aps.
unique_ap is a yes or no value that says if a second
wireless interface can connect to the same Access Point as the first interface.
Code Listing 3.3: blacklist_aps and unique_ap example |
blacklist_aps="'ESSID3' 'ESSID4'"
unique_ap="yes"
|
Ad-Hoc and Master Modes
If you want to set yourself up as an Ad-Hoc node if you fail to connect to any
Access Point in managed mode, you can do that too.
Code Listing 3.4: fallback to ad-hoc mode |
adhoc_essid_eth0="This Adhoc Node"
|
What about connecting to Ad-Hoc networks or running in Master mode to become an
Access Point? Here's a configuration just for that! You may need to specify WEP
keys as shown above.
Code Listing 3.5: sample ad-hoc/master configuration |
mode_eth0="ad-hoc"
essid_eth0="This Adhoc Node"
channel_eth0="9"
|
Important:
The below is taken verbatim from the BSD wavelan documentation found at the NetBSD
documentation. There are 14 channels possible; We are told that channels
1-11 are legal for North America, channels 1-13 for most of Europe, channels
10-13 for France, and only channel 14 for Japan. If in doubt, please refer to
the documentation that came with your card or access point. Make sure that the
channel you select is the same channel your access point (or the other card in
an ad-hoc network) is on. The default for cards sold in North America and most
of Europe is 3; the default for cards sold in France is 11, and the default for
cards sold in Japan is 14.
|
Troubleshooting Wireless Tools
There are some more variables you can use to help get your wireless up and
running due to driver or environment problems. Here's a table of other things
you can try.
| Variable |
Default Value |
Description |
| iwconfig_eth0 |
|
See the iwconfig man page for details on what to send iwconfig
|
| iwpriv_eth0 |
|
See the iwpriv man page for details on what to send iwpriv
|
| sleep_scan_eth0 |
0 |
The number of seconds to sleep before attempting to scan. This is needed
when the driver/firmware needs more time to active before it can be used.
|
| sleep_associate_eth0 |
5 |
The number of seconds to wait for the interface to associate with the
Access Point before moving onto the next one
|
| associate_test_eth0 |
MAC |
Some drivers do not reset the MAC address associated with an invalid one
when they lose or attempt association. Some drivers do not reset the
quality level when they lose or attempt association. Valid settings are
MAC, quality and all.
|
| scan_mode_eth0 |
|
Some drivers have to scan in ad-hoc mode, so if scanning fails
try setting ad-hoc here
|
| iwpriv_scan_pre_eth0 |
|
Sends some iwpriv commands to the interface before scanning.
See the iwpriv man page for more details.
|
| iwpriv_scan_post_eth0 |
|
Sends some iwpriv commands to the interface after scanning.
See the iwpriv man page for more details.
|
4.d. Defining network configuration per ESSID
Sometimes, you need a static IP when you connect to ESSID1 and you need
DHCP when you connect to ESSID2. In fact, most module variables can be
defined per ESSID. Here's how we do this.
Note:
These work if you're using WPA Supplicant or Wireless Tools.
|
Important:
You will need to consult the variable name documentation.
|
Code Listing 4.1: override network settings per ESSID |
config_ESSID1="192.168.0.3/24 brd 192.168.0.255"
routes_ESSID1="default via 192.168.0.1"
config_ESSID2="dhcp"
fallback_ESSID2="192.168.3.4/24"
fallback_route_ESSID2="default via 192.168.3.1"
dns_servers_ESSID1="192.168.0.1 192.168.0.2"
dns_domain_ESSID1="some.domain"
dns_search_domains_ESSID1="search.this.domain search.that.domain"
config_001122334455="dhcp"
dhcpcd_001122334455="-t 10"
dns_servers_001122334455="192.168.0.1 192.168.0.2"
|
[ << ]
[ < ]
[ Home ]
[ > ]
[ >> ]
The contents of this document, unless otherwise expressly stated, are licensed under the CC-BY-SA-2.5 license. The Gentoo Name and Logo Usage Guidelines apply.
|