Wireless/Configuration
From Gentoo Linux Wiki
| Installation • Kernel & Hardware • Networks • Portage • Software • System • X Server • Gaming • Non-x86 • Emulators • Misc |
[edit] Introduction
Configuration for most cards is done in /etc/conf.d/net. There are two things required for wireless network configuration. The standard network adapter configuration (static IP or DHCP, DNS, gateways, etc.) and authentication against a wireless access point. Read the previous guides, and refer to this page for explanations and additions. There are 2 tools to configure a wireless connection with:
- wireless-tools: Supports open and WEP Encryption. Configuration is in /etc/conf.d/net.
- wpa_supplicant: Supports open, WEP and WPA Encryption. Configuration is in /etc/conf.d/net and /etc/wpa_supplicant/wpa_supplicant.conf.
[edit] Kernel configuration
| Linux Kernel Configuration: Wireless configuration |
Networking --->
[*] Networking support
Wireless --->
<*> Improved wireless configuration API
The following is only used by very old drivers: --- Wireless extensions The selection between the following two depends on the driver being used. The first is the new stack, the second is the old: < > Generic IEEE 802.11 Networking Stack (mac80211)
<*> Generic IEEE 802.11 Networking Stack
[ ] Enable full debugging output
--- IEEE 802.11 WEP encryption (802.1x)
<*> IEEE 802.11i CCMP support
<*> IEEE 802.11i TKIP encryption
<*> Software MAC add-on to the IEEE 802.11 networking stack
[ ] Enable full debugging output
[*] Enable RAIODTAP headers for capibilities that can support it.
Turn on the following even if not using any of the drivers in the kernel: Device Drivers --->
Network device support --->
Wireless LAN --->
[*] Wireless LAN (IEEE 802.11)
... Select driver as needed if it's in the kernel source ...
The following should be on automatically by dependencies, but if not, turn it on: Cryptographic options ---> [*] Cryptographic API |
[edit] Checking if the driver loaded
You need to install wireless-tools first. Run iwconfig. If the driver is loaded and attached to the adapter a line should appear which doesn't end with no wireless extensions.. Example output:
| Code: iwconfig sample output |
wlan0 IEEE 802.11g ESSID:"<removed>"
Mode:Managed Frequency:2.437 GHz Access Point: <removed>
Bit Rate:54 Mb/s Tx-Power:15 dBm
Retry limit:15 RTS thr:off Fragment thr:off
Encryption key:<removed> Security mode:open
Power Management:off
Link Quality=85/100 Signal level=-48 dBm Noise level=-103 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:430 Missed beacon:0
|
[edit] Configuration
If you are having issues, it may help to see the full output of the Gentoo network init script to troubleshoot the connection. Set RC_VERBOSE=yes in /etc/conf.d/rc. Some people may have to bring the network and the card down before being able to bring the device up:
| Code: Commands |
ifconfig <device> down rmmod <module name> modprobe <module name> |
Please refer to dmesg if you have furthermore problems with connecting to an access point.
[edit] Required information
To configure your WLAN device, you need to know the following information about your access point:
- ESSID: The wireless access point's ID. A list of access points is available with iwlist scan.
- Encryption: None, WEP, WPA or others.
- Password (also known as "key" or "passphrase"): If using any encryption.
[edit] Configuring /etc/conf.d/net
It's possible to run completely different network settings per ESSID connected to - check the /etc/conf.d/wireless.example file for details on how to achieve this. Note: /etc/conf.d/wireless is deprecated. Please put all settings in /etc/conf.d/net. Also for more details look at the Gentoo Linux Networking Handbook.
A sample configuration file would look like this:
| File: /etc/conf.d/net snippet |
essid_ath1="YOUR_ACCESS_POINT" config_ath1=( "dhcp" ) dhcpcd_ath1="-t 30" # Timeout after 30 seconds |
| File: /etc/conf.d/net |
preferred_aps=( "MY-ESSID" ) |
Some cards (or drivers) may need some time to complete the association with the access point:
| File: /etc/conf.d/net |
sleep_scan_DEVICE="1" sleep_associate_DEVICE="25" |
Check the wireless section in /etc/conf.d/net.example for examples.
[edit] WEP Encryption
Up to 4 WEP keys can be specified for wireless networks:
| File: /etc/conf.d/net |
key_MY-ESSID="s:MY-WEPKEY enc open" |
If you are using an hexadecimal WEP key instead (containing only 0 to 9 digits and A to F letters) instead, the key argument must be passed without s:
| Code: hexadecimal WEP key |
key_home=( "<hexa WEP key> enc open" ) |
If you do not want to use the /etc/conf.d/net script, you can create a bash file which executes all commands manually. Note that this will only work with unencrypted or WEP protected access points. For WPA encryption, you need to use wpa_supplicant.
| File: wireless-connect.sh |
#!/bin/bash ifconfig <device> up iwconfig <device> key <WEP key> dhcpcd <device> |
Then make it executable:
chmod +x wireless-connect.sh
Many people put this in local.start to have it initiated at boot.
| File: /etc/conf.d/local.start |
# My init script to start the network /home/user/myscripts/wireless-connect |
[edit] WPA
The second way of configuring wireless, and the best way, is by using wpa_supplicant. To install, simply emerge wpa_supplicant. Once installed, you can edit the /etc/wpa_supplicant/wpa_supplicant.conf file by checking out the examples in /etc/wpa_supplicant/wpa_supplicant.conf.example (or if not there, check in /usr/share/doc/wpa_supplicant-?.?.?/, filling in your version number) This file contains many options, is well documented and is a little easier to setup for multiple APs than by using /etc/conf.d/wireless. A sample configuration file would look like this:
| File: /etc/wpa_supplicant/wpa_supplicant.conf snippet |
# This is a network block that connects to a specific unsecured access point.
# We give it a higher priority.
network={
ssid="YOUR_ACCESS_POINT_NAME"
key_mgmt=NONE
priority=5
}
# This is a network block that connects to any unsecured access point.
# We give it a low priority so any defined blocks are preferred.
network={
key_mgmt=NONE
priority=-9999999
}
|
You may also want to be able to configure wireless networks comfortable using wpa_gui which is very powerful and convenient. In order to use it as a user and, more important, to make it save the configs, you have to add followings to wpa_supplicant.conf:
| File: /etc/wpa_supplicant/wpa_supplicant.conf snippet |
ctrl_interface=/var/run/wpa_supplicant ctrl_interface_group=users update_config=1 |
The bonus in configuring your wireless setup using wpa_supplicant is that it supports all types of encryption currently used: WEP, WPA and even non-encrypted. Do not forget to compile the kernel modules necessary for encryption. These may be Networking -> IEEE 802.11i TKIP Encryption and similar ones.
To use wpa_supplicant over iwconfig for wireless configuration, put the following in /etc/conf.d/net:
| File: /etc/conf.d/net snippet |
modules=( "wpa_supplicant" ) # Users of madwifi add this: wpa_supplicant_ath0="-Dmadwifi" # Users of Intel ipw2100/2200 (Centrino) chips with older kernels add this: wpa_supplicant_ath0="-Dipw" wpa_timeout_ath0=60 # As of kernel 2.6.15 (and probably earlier), centrino users have to use wpa_supplicant_ath0="-Dwext -c /etc/wpa_supplicant/wpa_supplicant.conf" # wpa_supplicant.conf by default now is located in /etc/wpa_supplicant # but yours could be in /etc. wpa_timeout_ath0=60 |
Note: Replace ath0 as required with wlan0, eth1 etc. and madwifi with ndiswrapper or the correct drivers for your wireless card (see wpa_supplicant --help for a list of drivers).
Note: With ndiswrapper version 1.13 and newer, use -Dwext instead of -Dndiswrapper (ndiswrapper.sourceforge.net). Also make sure that you add "ap_scan=2" to your wpa_supplicant.conf if you want to connect to hidden networks.
Note: You will need to comment out any config_ESSID settings, as they do not work in conjunction with wpa_supplicant. If not, you will receive the following hard-to-read error:
Nov 13 06:14:20 yourhost wpa_cli: interface ath0 CONNECTED Nov 13 06:14:21 yourhost wpa_cli: executing '/etc/init.d/net.ath0 --quiet start' failed
[edit] Connect using the Gentoo networking init script
Create a link that corresponds to your network interface/device in /etc/init.d/ and then start it:
| Code: |
cd /etc/init.d ln -s net.lo net.DEVICE /etc/init.d/net.DEVICE start |
To start the Gentoo networking init script at boot: rc-update add net.<device> default.
[edit] Useful scripts
[edit] Wireless + Ethernet connections
Some computers (mostly laptops) have both ethernet and wireless connectors. Double network connection is generally not needed. Bringing up the wireless network interface can be prevented by the preup() function in /etc/conf.d/net (change wlan0 and eth0 as appropriate):
| Code: /etc/conf.d/net |
preup() {
if [[ ${IFACE} == "wlan0" ]]; then
if ifplugstatus | grep -q 'eth0: link beat detected'; then
ewarn "Wired connection on eth0 detected, aborting configuration on ${IFACE}"
return 1
fi
fi
return 0
}
|
[edit] Wireless + Ethernet (ifplugd)
If the wired ethernet device is controlled via ifplugd we are able to use /etc/ifplugd/ifplugd.action to fire up the wireless device as soon as the ethernet cord is removed and bring it down if the cord is plugged in again. Add the lines marked new below in /etc/ifplugd/ifplugd.action
| Code: /etc/ifplugd/ifplugd.action |
...
case "$2" in
up)
if [ "${INITNG}" = "yes" ]
then
ARGS="-u net/$1"
else
/etc/init.d/net.wlan0 --quiet stop # this line is new
modprobe -r iwl3945 # this line is new
ARGS="--quiet start"
fi
;;
down)
if [ "${INITNG}" = "yes" ]
then
ARGS="-d net/$1"
else
ARGS="--quiet stop"
modprobe iwl3945 # this line is new
/etc/init.d/net.wlan0 --quiet start # this line is new
fi
;;
...
|
[edit] Troubleshooting
[edit] Connection times out every time
According to ArchLinux Wiki, if the connection always times out, you should set the rate of the card to 5.5M:
| Code: Setting the rate to 5.5M |
iwconfig wlan0 rate 5.5M auto |
In Gentoo, this can be automated at startup by adding the following line to your /etc/conf.d/net:
| Code: /etc/conf.d/net |
rate_wlan0=( "5.5M auto" ) |
If this does not work for you, you could also try out 11M instead of 5.5M (see [1]). You can also try to change from pid to simple rate control algorithm by replacing this line config.mk:
| File: config.mk |
CONFIG_MAC80211_RC_DEFAULT=pid |
with:
| File: config.mk |
CONFIG_MAC80211_RC_DEFAULT=simple |
[edit] Failed to initialize WEP
If your card cannot be initialized due to an -12 error and you have error lines saying something like this:
| Code: dmesg |
wmaster0: Failed to initialize wep |
Be sure you compiled Generic IEEE 802.11 Networking Stack into kernel (and not as a module!)
| Linux Kernel Configuration: Wifi |
Networking --->
[*] Networking support
Wireless --->
<*> Generic IEEE 802.11 Networking Stack (mac80211)
|
[edit] Net services like Apache don't start if both wlan0 and eth0 aren't started
If RC strict is set to "yes", then it will require that all net devices are started before any of the net services are started, you need to set this to "no".
For baselayout-1: Open /etc/conf.d/rc and change RF_NET_STRICT_CHECKING to "NO"
For baselayout-2: Open /etc/rc.conf and change rc_depend_strict to "NO"
[edit] SIOCSIFADDR: No such device
It's a kernel or driver problem. Chances are you're using NDISwrapper and it's not configured correctly.
[edit] Prism based card behaving unreliably
Possibly cause by old buggy firmware. See here for a possible fix.
[edit] "Failed to initialize EAPOL state machines" error upon starting wpa_supplicant
Comment out the openssl lines in the wpa_supplicant config file:
| File: /etc/wpa_supplicant/wpa_supplicant.conf |
#opensc_engine_path=/usr/lib/opensc/engine_opensc.so #pkcs11_engine_path=/usr/lib/opensc/engine_pkcs11.so #pkcs11_module_path=/usr/lib/pkcs11/opensc-pkcs11.so |
[edit] Wireless extensions missing even though the device is a wireless adapter
Wireless-Extensions must be enabled in the kernel. wireless-tools must be reinstalled for the new kernel.
[edit] Links
- If your laptop needs different configurations depending on the network, this article on arping will be very helpful.
- WPA/WPA2/IEEE 802.1X Supplicant
