Gentoo Wiki


This article is part of the HOWTO series.
Installation Kernel & Hardware Networks Portage Software System X Server Gaming Non-x86 Emulators Misc



Setting up wireless on Gentoo is no easy task. It is particularly hard for those of us with Prism2-based devices with a USB connection like the Netgear MA111 (version 1) or the DLink DWL122, due to a lack of driver and software options. This guide should help you through the process.

Now also got it working succesfully with an Unex UR012i wireless USB adapter under Gentoo Linux. Read on for further instructions.


The goal here is to get you on an wireless network with either basic WEP or no encryption. Unfortunately, at this time doing so requires a specific command to be entered each time you want to join a network after booting. Hopefully in the future this guide can be improved with instructions to automatically join a network on boot.

This information has only been tested with a Netgear MA111 v1 wireless adapter on a desktop system with no encryption and basic 128-bit key "open system" WEP encryption. The kernel version is 2.6.14 and the wlan-ng software is version 0.2.2. Please update these instructions to expand the utility of this guide if you get them to work under more diverse conditions.

The following instructions are also tested with a Unex UR012i wireless USB adapter on a laptop system with no encryption and basic 128-bit key "open system" and "Both" (meaning open system and shared at the same time, at least that's what my router says ;-) ). The router I connect to is a Canyon CN-WF514. The kernel version is 2.6.18-gentoo-r6 (yes running gentoo ;-) ) and the software version is 0.2.8 which is a straight download of sources from the official linux-wlan-ng FTP: [1] which made the use of WEP encryption possible. The instructions below did work for me with the masked ebuild linux-wlan-ng-0.2.3-r2 from Gentoo Portage, but without the WEP encryption. As soon as I enabled WEP encryption on my router and in my adapter conf, a timeout occurs when trying to get a DHCP lease.


For ebuild from Gentoo Portage: The general flow goes like this:

  1. Configure your kernel
  2. Install the wlan-ng driver and client tools
  3. Configure same
  4. Join network

For installing sources from official linux-wlan-ng FTP:

  1. Configure your kernel just like when installing the ebuild from Portage
  2. Download latest sources (I have 0.2.8) from:
  3. Make the 'README' file (also on the FTP) available for offline reading (e.g. printing, saving locally, etc.)
  4. Stick to the instructions in this readme file for the type of adapter you have (e.g. USB, PCI, PCMCIA, etc.) and ignore the instructions below (for instance you do need to use the /etc/init.d/wlan script now ;-) )

When having experience with compiling packages, these instructions shouldn't be hard to follow.

After having installed and configured the settings to your specific situation, according to the instructions in the 'README' file, then at reboot it should suffice to load the prism2_usb (if you've got an USB adapter ofcourse) kernel module with:

# modprobe prism2_usb prism2_doreset=1

and startup the wlan0 interface by running the wlan init script:

# /etc/init.d/wlan start

Then get an IP address from your DHCP server (if you have one on the network) by:

# dhcpcd -d wlan0

or configure one manually with 'ifconfig wlan0 <your IP address>'. Ofcourse do not forget to set your DNS in /etc/resolv.conf.

These instructions can ofcourse be done at boot time, at least the loading of the kernel module. Initiating the wlan interface will connect to your default wlan network (ESSID set in wlan.conf), but being mobile (e.g. laptop) could mean that when you boot again you're at a different geographical location, thus you connect to another wlan. This means that you need to change the default wlan network in wlan.conf (by setting another ESSID) and then run the wlan init script (/etc/init.d/wlan start).

Important side-note! It seems that when rebooting Linux the USB adapter's hardware isn't reset. After some trial and error, I found out that you need to unplug and replug the adapter, then if the kernel modules are loaded the wlan init script will work again. Otherwise you'll get an error which says something like: 'No interface wlan0 found'.

Thusfar my experiences with linux-wlan-ng driver under Gentoo. (MaGaM)

Configuring the kernel

To establish that you do want wireless in your kernel:

Linux Kernel Configuration: Wireless in 2.6.14
Device Drivers --->
  Network device support --->
    Wireless LAN (non-hamradio) --->
      [*] Wireless LAN drivers (non-hamradio) & Wireless Extensions

Note you do not need any of the kernel modules offered here; the one you need will be installed by wlan-ng.

Installing drivers and software

With the Prism2 USB devices, only the wlan-ng package has the necessary drivers and software to get you online. In most wireless setups, the driver (hostap, ndiswrapper) is separate from the client tools to configure the wireless device (wpa_supplicant, wireless-tools). In wlan-ng, both parts are in one package. You may see notices in that wlan-ng is not compatible with baselayout (e.g. in the official Gentoo Wireless Documentation). What this means is that in most wireless setups which use the other tools mentioned here, some standards have been agreed on as to where to put configuration information so that you can interchange drivers and client tools. Since wlan-ng works alone, it does not follow these standards.

At the time of this writing, the only stable version of the linux-wlan-ng package is 0.2.0, but this does not compile with 2.6 series kernels. You'll need to install a masked version. Add these lines to your /etc/package/keywords:

File: /etc/portage/package.keywords
net-wireless/linux-wlan-ng ~x86
net-wireless/linux-wlan-ng-modules ~x86
net-wireless/linux-wlan-ng-utils ~x86
net-wireless/linux-wlan-ng-firmware ~x86
Note: Confirm you have usb in your use flags, that /usr/src/linux points to your current kernel, then emerge version 0.2.2 with the command
# emerge =linux-wlan-ng-0.2.2
Note: The linux-wlan-ng-firmware didnt fit my dwl-122 so I found the right firmware on this page. 1.74 works here.

This will also install version 0.2.2 of the other packages.

You will see a note at the end of the linux-wlan-ng ebuild that you need to add iface_wlan0 to your /etc/conf.d/net. This may be true in cases where the wireless settings could be configured at boot, but since we do it manually after boot, this is not important.

Configuring the software

There are two modifications to your Gentoo configuration files you need to make to get this working. First, you need to provide the prism2_usb kernel module with an option to reset your device on loading:

File: /etc/modules.autoload.d/kernel-2.6
prism2_usb prism2_doreset=1

Then, you need to setup an alias for the wlan0 interface. This could be in any file in /etc/modprobe.d/; wlan-ng is good.

File: /etc/modprobe.d/wlan-ng
alias wlan0 prism2_usb

Update your modules configuration, and load the new module.

# update-modules
# modprobe prism2_usb

Next, you need to setup your wireless adapter. Idealistic instructions can be found in /usr/share/doc/linux-wlan-ng*/README, (gzipped by default) but they do not exactly work in our case. Instead, we use a modified version of these instructions. First, activate the wireless interface:

# wlanctl-ng wlan0 lnxreq_ifstate ifstate=enable



Then, bind the wireless adapter to your network:

#wlanctl-ng wlan0 lnxreq_autojoin ssid=<your ssid> authtype=opensystem


ssid='<your ssid>'

Join the network

Next, do not run the init script in /etc/init.d/wlan. It will just give you an error if you do. Instead, just ask your friendly neighborhood DHCP server for an address:

# dhcpcd -d wlan0


dhcpcd: MAC address = xx:xx:xx:xx:xx:xx
dhcpcd: your IP address = 192.168.xx.xx

And voila! You should be set. (Of course, if you don't use DHCP, setup the wlan0 interface to your liking.)

From here on out, after you restart, just run the last three commands (two wlanctl-ng and one dhcpcd) to join the network again.

Optional Extras

While the above instructions should be enough to get you online, you may want to do more.

Enable WEP

Although it would be nice to use WPA or WPA2 with this setup, only WEP is possible. Still, it's better than nothing.

To enable WEP, you have to create a dedicated configuration file for the network you are going to connect to. First, copy /etc/conf.d/wlancfg-DEFAULT to /etc/conf.d/wlancfg-NetworkName, where NetworkName is the name of the network. It helps if the network name is simple and has no spaces, but if you need to you can include spaces in the filename. Open that file and change some of the settings:

File: /etc/conf.d/wlancfg-NetworkName
# [Dis/En]able WEP.  Settings only matter if PrivacyInvoked is true
lnxreq_hostWEPEncrypt=true     # true|false                         <--- change to true
lnxreq_hostWEPDecrypt=true     # true|false                         <--- change to true
dot11PrivacyInvoked=true	# true|false                        <--- change to true
dot11WEPDefaultKeyID=0		# 0|1|2|3
dot11ExcludeUnencrypted=true	# true|false, in AP this means WEP is required.

# If PRIV_GENSTR is not empty, use PRIV_GENTSTR to generate 
#  keys (just a convenience)
# add-ons/ in the tarball contains other key generators.
#PRIV_GENERATOR=/sbin/nwepgen	# nwepgen, Neesus compatible        <--- comment out to be safe, probably can leave as is
#PRIV_KEY128=false		# keylength to generate             <--- comment out to be safe, probably can leave as is
#PRIV_GENSTR=""                                                     <--- comment out to be safe, probably can leave as is

# or set them explicitly.  Set genstr or keys, not both.
dot11WEPDefaultKey0=01:23:45:67:89:1A:BC:DE:F0:12:34:56:78          <--- replace with your WEP key
                                # format: xx:xx:xx:xx:xx   or 
dot11WEPDefaultKey1=		#         xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx
dot11WEPDefaultKey2=		#  e.g.   01:20:03:40:05   or
dot11WEPDefaultKey3=		#         01:02:03:04:05:06:07:08:09:0a:0b:0c:0d

Next, you need to tell wlan-ng that in general, it should try to connect to this network. That is done near the end of /etc/conf.d/wlan.conf

File: /etc/conf.d/wlancfg-NetworkName

Replace NetworkName with the name of the network you've been configuring.

Lastly, after you boot from this point on, you'll only want to issue the first of the two wlanctl-ng commands from above; if you issue the second, it will attempt to join your network with no encryption. Also, in Linux it is not trivial to have two network interfaces operating on the same subnet at the same time, so your DHCP request might not be answered if you still have eth0 active. To take it offline

# ifconfig eth0 down

At this point the dhcpcd command should work.

More information can be found in the readme that came with the linux-wlan-ng package. Note that while that readme and the configuration files themselves talk about putting your configuration in /etc/wlan, that is incorrect: you do want to use /etc/conf.d.

Retrieved from ""

Last modified: Sat, 30 Aug 2008 20:37:00 +0000 Hits: 9,600