Gentoo Linux wireless USB success: Netgear WG111, ndiswrapper, WPA

After conquering the Netgear WG311 PCI wifi adapter on my desktop system, I wanted to get a fast (802.11g) and secure (WPA) USB wireless network adapter working in Linux, for my car stereo computer and for my fiancee's laptop. Here's the complete HOWTO. This was done on a Pentium-III notebook running 2.6.10-gentoo-r6, with USB1 (UHCI) ports, i.e. no USB2.

I bought the Netgear WG111 USB wireless network adapter, which is an 802.11b/g device, supporting 11 or 54 Mbps. (Note that the WG111U and WG111T are different devices than the WG111.) I had searched for info on this device before and discovered that ndiswrapper supports it, so to begin I installed ndiswrapper and wireless-tools:

# emerge -vabk wireless-tools
# emerge -vabk ndiswrapper

...which got me w-t version 27-r1 and ndiswrapper version 1.1-r1.

I ran the lsusb command to determine my adapter's usbid, which is 0846:4220. I then found the corresponding entry on the ndiswrapper supported devices list. According to that page, the WG111v1 has a Prism54 (Intersil 3886 and NetChip NET2280) chipset.

The ndiswrapper page directs you to the Netgear site to get the Windows driver for your device. My device's serial number starts with WG16, so according to the Netgear Knowledgebase that means it's a WG111v1. Serial numbers starting with WG72 are also v1s; those starting with WG41 are WG111v2 devices.

So I pick v1 and it leads me to this driver file: wg111_setup.exe. Following the ndiswrapper installation instructions I run:

# cabextract wg111_setup.exe
# unshield Disk1/

This got me a bunch of files, one of which was netwg111.inf, so I ran:

# ndiswrapper -i netwg111.inf install the driver to /etc/ndiswrapper/. The command "ndiswrapper -l" then showed that the driver (and the adapter) were present.

I modprobe ndiswrapper and then run dmesg, and I see this:

ndiswrapper version 1.1 loaded (preempt=yes,smp=no)
ndiswrapper: driver netwg111 (NETGEAR, Inc.,03/03/2004,
ndiswrapper (NdisWriteErrorLogEntry:273): log: C000138A, count: 3
	(00000103), return address: d8998fbc, entry: d89a77c2
	offset: 4294907898
ndiswrapper (NdisWriteErrorLogEntry:273): log: C000138A, count: 3
	(c0000001), return address: d8994fe3, entry: d89a77c2
	offset: 4294891553
wlan0: ndiswrapper ethernet device 00:09:5b:b5:10:d6 using driver
	netwg111, configuration file 0846:4220.0.conf
wlan0: encryption modes supported: WEP, WPA with TKIP, WPA with
usbcore: registered new driver ndiswrapper

And now iwconfig shows my wlan0 device, and "iwlist wlan0 scan" shows all the wireless access points (APs) in range.

I want to use WPA (since WEP is now fairly insecure) so I do:

# emerge -vabk wpa_supplicant

...which gets me version 0.3.8-r1. I then create the file /etc/wpa_supplicant.conf containing only this:



	# Don't put the password in here like this...
	#psk="my WPA password"
	# ...instead, use the wpa_passphrase utility to
	# generate a hash from your SSID and password,
	# and enter that hash here:


...and then I chmod it 0600 so that only root can read it, since it contains the network credentials.

Finally, I run:

# ifconfig wlan0 up
# wpa_supplicant -Dndiswrapper -iwlan0 -c/etc/wpa_supplicant.conf -dd

That wpa_supplicant command shows lots of verbose output, from which I can see that it has properly connected to my router. The ifconfig and iwconfig commands also now show wlan0 as active (it shows the AP MAC address that isn't all zeros).

Now, to permanently set my network settings, I put this into /etc/conf.d/net:

modules=( "wpa_supplicant" )
# optionally set the IP and router for your wireless card to use.
# if you're using DHCP you can skip these.
ifconfig_wlan0=( " netmask" )
routes_wlan0=( "default gw" )

Create a net.wlan0 link:

# cd /etc/init.d
# ln -s net.l0 net.wlan0 that we can use rc-update to start the wireless device at startup:

# rc-update add net.wlan0 default

And add this single line to /etc/modules.autoload.d/kernel-2.6 to load ndiswrapper (and thus the driver) at startup:


Finally, run:

# /etc/init.d/net.wlan0 start start the device. Then run the route command and you should see that some of your routes are running through the wlan0 interface. But since you probably had a wired ethernet connection already, your default route still uses that. Run:

# /etc/init.d/net.eth0 stop && /etc/init.d/net.wlan0 restart disable your wired connection, and then re-start your wireless connection so the default route goes through it.

To permanently disable your old wired connection, so that wlan0 gets the default route at startup from now on, do:

# rc-update del net.eth0 default

Finally, note this from the ndiswrapper wiki FAQ: "If you are using 2.6 kernels, make sure 4K stacks are not used i.e., disable CONFIG_4KSTACKS" in your kernel.  Apparently crashes may result otherwise.

(Note: I also posted this in the Gentoo Forums.)