Saturday, March 24, 2007

Configuring wireless card in gentoo

Few information before we proceed to make your Gentoo access internet using wi-fi:

1. The default command line text editor in Gentoo is nano.

2. The network cards need to be activated from /etc/init.d

3. Edit the configuration file /etc/conf.d/net

4. To start,stop.restart use /etc/init.d/net.eth0 start/stop/restart

There are currently two ways to configure wireless networking in Gentoo. The first way is by using the options documented in /etc/conf.d/wireless.example to setup a full configuration, which uses iwconfig (located in the "wireless-tools" ebuild). The wireless.example file is well documented and should list everything you need to get started, including information on setting up WEP. Be sure to check this file for variable changes/additions/removals for new versions!

These wireless settings are held in /etc/conf.d/wireless - but could be held in /etc/conf.d/net as well

Here's a sample config for /etc/conf.d/wireless:





File: /etc/conf.d/wireless snippet



key_YOUR-ESSID="s:mywepkey enc open"
preferred_aps=( "YOUR-ESSID" )



Replace YOUR-ESSID with your ESSID and mywepkey with your WEP key - if it's needed
. Some cards (or drivers) may need some time to complete the association with the access point. Add something like this, if needed:








File: /etc/conf.d/wireless snippet



sleep_scan_wlan0="1"
sleep_associate_wlan0="25"



To troubleshoot the connection, set RC_VERBOSE=yes in /etc/conf.d/rc for more wireless output.

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.

To connect, first create a link that corresponds to your network inteface in /etc/init.d and then start it:








Code: in /etc/init.d


# cd /etc/init.d
# ln -s net.lo net.eth0
# ./net.eth0 start


To start the interface automatically, execute:








Code: /


# rc-update add net.eth0 default


Of course, one can also create a script to connect to your home protected wireless wep connection, for example:








Code: /root/wireless


#!/bin/bash
ifconfig eth0 down
rmmod ipw2200
modprobe ipw2200
ifconfig eth0 up
iwconfig eth0 key E7D6CA05773D038378F5E26748 #change this to your wep key
dhcpcd eth0


then make the wireless executable:






Code:

# chmod +x wireless


To use the script just do






Code:

# ./wireless


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 /usr/share/doc/wpa_supplicant-0.4.9/wpa_supplicant.conf.example.gz. This file contains many options, and is well documented, and is a little easier to setup for multiple APs than by using /etc/conf.d/wireless. 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.

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: 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

FAQ


  • Q. How I can connect to several wireless networks at the same time?
  • A. You can't, at least not with only one wireless card. Just as a single ethernet card cannot be on two (physical) networks at once, a wireless card can only be associated with one wireless network at once. However, with the proper configuration, a card could be configured to intelligently switch between available wireless networks dynamically. wpa_supplicant makes this an easier task than with wireless-tools, but neither is quite as simple as in Windows XP at this time.




  • Q. I don't have net.wlan0, net.eth1, net.ath0 or similar in /etc/init.d!
  • A. Read up on Gentoo networking in their handbook:

http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=8#doc_chap2

Link to net.lo instead of net.eth0 if you are using a current baselayout (>=1.11).




  • Q. I'm seeing Wireless extensions not found for $interface - but it's a wireless device!
  • A. You need to enable wireless-extensions in your kernel.

To do this, enable the following config options in /usr/src/linux/.config






Linux Kernel Configuration:


CONFIG_NET_RADIO=y
CONFIG_NET_WIRELESS=y


Then recompile your kernel and modules and re-install them
If your driver is external then re-compile and re-install that.
Finally, re-emerge wireless-tools against the new kernel and driver



No comments: