How-To: Wireless Networking in Linux
So I've had a laptop with a wireless networking card for a long time, but (knowing it would be difficult) decided to not set up wireless networking under Linux, and instead used Windows if I needed that. I recently decided that, yes, I did want to get wi-fi working under Linux, so decided to make this my new project. And difficult it was -- it took 3 days of work, and many hours on each of those days. Lots of things were tried, some things broke, but in the end I am now posting this blog entry from my laptop in Linux, so it must have worked. :) And, much like with secure file sharing under Windows, I've decided to document what I did -- both for myself, and the benefit of the greater internet.
First, let me describe my set up. My laptop is a Dell Inspiron 1100, but I don't think that matters much here. My wireless card of choice is a D-Link DWL-G630, which is an 802.11g card. I don't guarantee that this guide will help any wireless card OTHER than that one -- in fact, I don't really even guarantee that this will help other people with the same card! All I know is that it worked for me. Up until recently I was running Mandrake 10.0 Official, and just the other day had switched to Fedora Core 4. However, I wasn't requiring a specific OS (other than it should be relatively mainstream and modern). This ended up being a good area of flexibility, as you will see.
Now, the first thing I did was look around to see if there were any native Linux drivers for this card. If I could find that, then I'd be done! Unfortunately, I could not find any. So that left me with two options -- the $20 Linuxant DriverLoader, or the free ndiswrapper. Both do the same thing: they allow you to load the Windows driver for your NIC under Linux. This seemed to be a good option. Since I am cheap, I chose ndiswrapper.
Now from this point on, there were lots of false attempts and turmoil, so I will skip over most of what I tried, and focus on the method that worked. I will, however, note the major pitfalls in case other people fall into them.
The first problem is obtaining the driver for your wireless NIC. For my card, the driver which came on the CD with my card worked fine. Also, you can't just use the *.inf file on the CD, you have to take the entire WinXP/ directory (which contains the *.inf file).
Now, I found that Fedora Core 4 does not play well with this driver. As many people know, versions of Fedora which use the 2.6 kernel use 4K stacks for processes. This driver requires more than that (and freezes the system without it!). I searched online extensively, but could not find any way to patch the stock FC4 kernel, or any way to re-compile it with 4K stacks disabled. So, this required me to downgrade to Fedora Core 3, which is unfortunate.
However, even FC3 has only 4K stacks. In order to fix that, you need to download a new, patched, kernel, from Linuxant, which supports 16K stacks. I found that patching the stock FC3 kernel caused problems. So, my advice is that after you install Fedora Core 3, upgrade to the newest kernel available through yum (or up2date). The kernel version should be 2.6.11-1.35. Just open up a terminal and issue a
yum update kernel
to get it. Then, reboot to make sure everything still works.
Now, determine your architecture, which should be either i586 or i686. To determine this, open up a terminal and type
rpm -q --qf '%{ARCH}\n' kernel
Now, download the patched kernel corresponding to your architecture: i586 or i686. You'll want the package corresponding to your kernel, which should be at the top of the list (don't download the SMP version! ... unless you are running an SMP version of Linux. If you aren't sure, you probably aren't). The reason FC4 is unusable is that there is not a patched kernel available for it.
Once you have that new kernel, unzip the file you downloaded, and install the new kernel, by opening up a terminal and typing
rpm -Uvh FILENAME
where FILENAME is the file that was in the zip file, should end in .rpm. Now, reboot, and hopefully everything still works.
Now, we have an upgraded kernel, with support for 16K stacks. Now we need to actually install the ndiswrapper program. Go to this website and download the newest ndiswrapper package. Untar this file by opening a terminal and issuing the command:
tar xzf FILENAME
where FILENAME is the file you downloaded, should end in .tar.gz. You'll now have an ndiswrapper directory. "cd" into it. Now you have to become root: issue the "su" command, and enter your root password when prompted. Now type "make", and then "make install". Ideally, you should not get any errors during this.
Now, copy the entire Drivers/WinXP directory off of your driver CD and into your home directory. "cd" into that directory, and type
/usr/sbin/ndiswrapper -i tnet1130.inf
This tells ndiswrapper to load that driver, which is the Windows driver for the DWL-G630 card. Now, make sure that your DWL-G630 card is inserted in the PCMCIA slot. Once it is, if you type
/usr/sbin/ndiswrapper -l
(that's dash-L), you should see your driver , and it should say "hardware present".
Now, load the ndiswrapper module. to do this, type
/sbin/modprobe ndiswrapper
If all is well, the lights on the wireless card should light up now. Type
/usr/sbin/ndiswrapper -m
to associate ndiswrapper with your wlan0 device. It's probably worth noting here that from this point on, your wireless card will be referred to as wlan0 by Linux. Just like your wired NIC is probably eth0.
Now you need to make sure that wireless-tools is installed. I believe that this package comes installed with Fedora. To check, try issuing the command
/sbin/iwconfig
(still as root, of course). If that command succeeds, you are all set. If not, you need to install this package, which can probably be installed with a simple "yum install wireless-tools".
Now, you can set the SSID of the wireless network you want to connect to by issuing the command
/sbin/iwconfig wlan0 essid ESSID
where ESSID is the name of the network. You can list visible networks by using the command
/sbin/iwlist wlan0 scan
Of course, if your access point doesn't broadcast its SSID, you won't see it here until after you've issued the first command.
Now, issue the command
/sbin/iwconfig wlan0 mode Managed
If your access point requires a key for authentication, issue the command
/sbin/iwconfig wlan0 key restricted 0xHEXKEY
where HEXKEY is the hex representation of your key.
Now, issue the command
/sbin/ifconfig wlan0 up
Note that that command is i*F*config, not i*W*config. Lastly, issue the command
/sbin/dhclient wlan0
This should cause your wireless interface to bind to an IP address. Now it should be useable.
At this point, you can use Fedora's graphical network config tool to further configure the interface. This tool is available from Applications -> System Settings -> Network. This tool will let you change the SSID, key, and other options. You can also set the adapter to be started automatically at boot time here.
Well, that's everything I did to get my card working. I hope it helps other people!
<< Home