HOWTO Wireless Configuration and Startup
From Gentoo Linux Wiki
Contents |
| Installation • Kernel & Hardware • Networks • Portage • Software • System • X Server • Gaming • Non-x86 • Emulators • Misc |
[edit] Configuration by hand
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.
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
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 |
Now you should be able to scan the area for router ESSIDS.
wlanconfig DEVICE list scan
or
iwlist DEVICE scanning
If iwlist is not available as a command, you need to emerge net-wireless/wireless-tools:
# emerge wireless-tools
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:
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
Connect Manually
Sometimes the Gentoo networking init script won't work for you, or you would just prefer to do it quicker. You'll likely have to add more details than just the WEP key, like channel, essid... See the MadWifi document listed above.
ifconfig DEVICE up iwconfig DEVICE key WEPKEY... dhcpcd DEVICE
If you're roaming and don't require a WEPKEY,
iwconfig DEVICE essid any
This command will connect to the strongest station.
Some people may have to bring the network and the card down before being able to bring the device up:
ifconfig DEVICE down rmmod MODULENAME modprobe MODULENAME
Of course, one can also create a script to connect to your wireless connection, for example:
| File: /home/user/myscripts/wireless-connect |
#!/bin/bash ifconfig DEVICE up iwconfig DEVICE key E7D6CA05773D038378F5E26748 dhcpcd DEVICE |
Then make it executable:
chmod +x wireless-connect
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] Configuration using wpa_supplicant
The second way of configuring wireless, and in my opinion 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] Madwifi and Wpa_supplicant
Madwifi support depends on the version of wpa_supplicant (see bug 110791). Check whether the package has a madwifi useflag (and don't forget to add it to your /etc/make.conf). As of writing, all versions in Portage have this useflag.
[edit] Links
- If your laptop needs different configurations depending on the network, this article on arping will be very helpful.
