Ath9k is the latest wireless driver for the newer Atheros chipsets and just like the MadWifi driver could be used to put your NIC in a promiscuous mode, do packet injection, etc. in order to crack WEP.
Check the compatibility of your wireless NIC first.
To find out what kind of chipset you have, run:
lspci | grep -i wireless
The ath9k driver is present in any kernel starting with version 2.6.27. The oldest supported ath9k version comes with kernel 2.6.32. That means most likely you already have the driver and there is no need to download it, all you have to do is enable it.
The general steps in order to enable ath9k are:
- Get the kernel source and some necessary packages
- Configure the kernel
- Compile and install the kernel
- Configure grub to boot from the new kernel image
Some steps might sound a bit intimidating, but actually they are very easy to do.
Since you will be running a lot of commands as root, it would be more convenient to open a bash shell as root instead of preceding all commands with sudo. The easiest way to do this is to run the following command it terminal:
$ sudo bash
Note: The above command has nothing to do with enabling the root login. I strongly recommend to never enable the root login due to serious security risks! Some blogs might ask you to do that, but there is hardly ever any reason to do this.
1. Get the kernel source and some necessary packages
# aptitude install git-core build-essential kernel-package qt3-dev-tools libqt3-mt-dev fakeroot
# apt-get install linux-source
The above command downloaded the kernel source tarball in /usr/src.
In my case the kernel version I am working with is 2.6.32 (patch level 15). Replace these numbers with the version of your kernel source.
Now lets cd to the place we downloaded the kernel source:
# cd /usr/src
Uncompress and extract the kernel source:
# tar xjvf linux-source-2.6.32.tar.bz2
# cd linux-source-2.6.32
2. Configure the kernel
Before configuring the kernel, lets import the configuration of the currently running kernel. This way we do not miss to enable something we currently have and need:
# cp -vi /boot/config-`uname -r` .config
Now we are ready to add a few configurations to the kernel:
# make xconfig
This opens up an xwindow with a hierarchical structure representing the kernel settings:
First enable mac80211:
Networking --->
Wireless --->
Improved wireless configuration API
Generic IEEE 802.11 Networking Stack (mac80211)
You can then enable ath9k in the kernel configuration under:
Device Drivers --->
[*] Network device support --->
Wireless LAN --->
Atheros 802.11n wireless cards support
If you re-used the existing configuration, note that Ubuntu kernels build with debugging information on, which makes the resulting kernel modules (*.ko files) much larger than they would otherwise be. To turn this off, go into “Kernel hacking”; then, under “Kernel debugging”, turn OFF “Compile the kernel with debug info”.
Save changes and exit.
3. Compile and install the kernel
First, let’s ensure a “clean” build:
# make-kpkg clean
Since the kernel compilation might take some time, it is best to set the CONCURRENCY_LEVEL variable, so that it can take a full advantage of the multiple processors or mulitple CPU cores on the machine. The CONCURRENCY_LEVEL variable is equal to the number of processors on the machine plus one. So if your machine has a dual core processor the variable will be equal to 3. To find out how many processors or cores your computer has run:
# lshw -C CPU
In my case I get cpu:0 and cpu:1, which means that I have a dual core processor.
Besides the CONCURRENCY_LEVEL, the only other thing we need to pay attention to here is the “–append-to-version” option. It basically adds that string to the end of the kernel name and could be set to anything. That gives you the opportunity to put there something meaningful to distingush the kernel from the other ones. In this case I called it “-mykernel”.
Now you are ready to compile:
# CONCURRENCY_LEVEL=3 fakeroot make-kpkg --initrd --append-to-version=-mykernel kernel-image kernel-headers
If you want to see the ubuntu splash screen (or use text mode) before you get to X instead of just a black screen, you’ll want to make sure the framebuffer driver loads:
# echo vesafb >> /etc/initramfs-tools/modules
# echo fbcon >> /etc/initramfs-tools/modules
Now install the kernel and the headers from the created Debian packages:
# dpkg -i linux-image-2.6.32.15+drm33.5-mykernel_2.6.32.15+drm33.5-mykernel-10.00.Custom_i386.deb
# dpkg -i linux-headers-2.6.32.15+drm33.5-mykernel_2.6.32.15+drm33.5-mykernel-10.00.Custom_i386.deb
Now let’s generate an initramfs (initrd) image, that will be loaded up by grub on boot:
# cd /boot
To avoid confusion with the next command, here is what my /boot directory contains before I run the mkinitramfs command:
# ls -altr
total 27700
-rw-r--r-- 1 root root 160280 2010-03-23 05:37 memtest86+.bin
-rw-r--r-- 1 root root 4034976 2010-08-20 14:22 vmlinuz-2.6.32-24-generic
-rw-r--r-- 1 root root 1689036 2010-08-20 14:22 System.map-2.6.32-24-generic
-rw-r--r-- 1 root root 115905 2010-08-20 14:22 config-2.6.32-24-generic
-rw-r--r-- 1 root root 651618 2010-08-20 14:22 abi-2.6.32-24-generic
-rw-r--r-- 1 root root 1196 2010-08-20 14:24 vmcoreinfo-2.6.32-24-generic
drwxr-xr-x 22 root root 4096 2010-09-04 15:27 ..
-rw-r--r-- 1 root root 0 2010-09-07 22:11 initrd.img-2.6.31-wl
-rw-r--r-- 1 root root 7977082 2010-09-07 22:49 initrd.img-2.6.32-24-generic
-rw-r--r-- 1 root root 115845 2010-09-08 02:13 config-2.6.32.15+drm33.5-mykernel
-rw-r--r-- 1 root root 3999488 2010-09-08 07:38 vmlinuz-2.6.32.15+drm33.5-mykernel
-rw-r--r-- 1 root root 1644782 2010-09-08 07:38 System.map-2.6.32.15+drm33.5-mykernel
drwxr-xr-x 3 root root 4096 2010-09-08 16:01 .
Run the mkinitramfs to generate the initrd:
# mkinitramfs -k -o initrd.img-2.6.32.15+drm33.5-mykernel 2.6.32.15+drm33.5-mykernel
4. Configure grub to boot from the new kernel image
# update-grub2
The last thing to do is to ensure that the ath9k module loads on boot. That will avoid running modprobe ath9k after each reboot.
So lets add the line ath9k to the end of the /etc/modules file:
# echo ath9k >> /etc/modules
Now reboot your computer and chose the new kernel to boot into from the grub menu.
Your wireless NIC should be working now using the ath9k driver.
Credits:
- I’d like to thank Jeff Rall for letting me work with him on this on his computer!
- The Linux Wireless Community
- Ubuntu Kernel Compile
- How to install the development version of atk9k