Creating a wireless access point on Arch Linux Monday, Sep 14 2009 

I’ve wanted my Linux server (Arch Linux 2.6.30-ARCH) to act as a wireless access point. I had to overcome a few issues while configuring the access point. I will be using WEP as encryption for my new wireless access point.

I had to install a few packages before I could start:

pacman -S bridge-utils hostapd wireless-tools

Here you can see my NIC and my wireless pci card:

4 root@archserver $ lspci | grep Ethernet
00:08.0 Ethernet controller: Atheros Communications Inc. Atheros AR5001X+ Wireless Network Adapter (rev 01)
00:09.0 Ethernet controller: D-Link System Inc DGE-528T Gigabit Ethernet Adapter (rev 10)

Arch Linux comes with the ath5k module for this wireless card, unfortunately I wasn’t able to put my wlan0 into Master Mode with this module.

I needed the ath_pci module, which is delivered by madwifi. So I’ve executed:
pacman -S madwifi

So in order to put my wireless into Master mode I’ve commited a few necessary changes.
First of all, I had to blacklist the default ath5k module. You can do this by modifying your /etc/rc.conf file.
Change the MODULES array of your rc.conf, and make sure an note of exclamation is present before ath5k. This module has been blacklisted now.

16 root@archserver $ cat /etc/rc.conf | grep MODULES
# MODULES: Modules to load at boot-up. Prefix with a ! to blacklist.
# NOTE: Use of 'MOD_BLACKLIST' is deprecated. Please use ! in the MODULES array.

Then I’ve inserted the new module who supports Master Mode into the Linux kernel. Executing iwconfig ath0 mode Master did not give any error.

modprobe ath_pci
iwconfig ath0 mode Master

Now you have to modify /etc/modprobe.d/modprobe.conf in order to use ath_pci with the ap option (for access point).

alias ath0 hostap_pci
options ath_pci autocreate=ap

After that I had to modify /etc/rc.conf, Arch Linux its main configuration file. I’m using dhcp for eth0. The interfaces array declares all the available interfaces. (deuh!) The bridge device is named br0, and it will be a bridge between eth0 (wired) and ath0. (wireless)

br0="br0 netmask up"
INTERFACES=(lo eth0 ath0 br0)

Changing /etc/conf.d/wireless or /etc/conf.d/bridges gave me some trouble, I’ve decided to edit /etc/rc.local (the multi-user start-up script.) This is my /etc/rc.local:

29 root@archserver $ cat /etc/rc.local
# /etc/rc.local: Local multi-user startup script.
modprobe hostap_pci
iwconfig ath0 mode master essid phar0z key A1B3C5D7E0 channel 1
brctl addbr br0
brctl addif br0 ath0
brctl addif br0 eth0
ifconfig br0 up
dhclient br0
dhclient eth0
/etc/rc.d/sshd restart

You may have noticed I prefer dhclient above dhcpcd.

pacman -R dhcpcd && pacman -S dhclient

I noticed there wasn’t a good Arch-oriented access point guide on the net. As you can see this configuration worked fine for me:

30 root@archserver $ brctl show br0
bridge name bridge id STP enabled interfaces
br0 8000.00179a76b010 no ath0

Now I will scan for wireless essids on my Ubuntu laptop. I execute iwlist wlan0 scan on my notebook:

wlan0 Scan completed :
Cell 01 - Address: 00:15:E9:F5:62:58
Frequency:2.412 GHz (Channel 1)
Quality=47/70 Signal level=-63 dBm
Encryption key:on
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 6 Mb/s
12 Mb/s; 24 Mb/s; 36 Mb/s
Bit Rates:9 Mb/s; 18 Mb/s; 48 Mb/s; 54 Mb/s
Extra: Last beacon: 4300ms ago
IE: Unknown: 0005646C696E6B
IE: Unknown: 010882848B960C183048
IE: Unknown: 030101
IE: Unknown: DD0600032F010001
IE: Unknown: 2A0100
IE: Unknown: 32041224606C
IE: Unknown: DD0900037F010100060000
IE: Unknown: DD0C00037F020101DB0002A44000

Cell 02 - Address: 00:17:9A:76:B0:10
Frequency:2.437 GHz (Channel 6)
Quality=70/70 Signal level=-27 dBm
Encryption key:on
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 6 Mb/s; 9 Mb/s
11 Mb/s; 12 Mb/s; 18 Mb/s
Bit Rates:24 Mb/s; 36 Mb/s; 48 Mb/s; 54 Mb/s
Extra: Last beacon: 4040ms ago
IE: Unknown: 000670686172307A
IE: Unknown: 010882848B0C12961824
IE: Unknown: 030106
IE: Unknown: 07064E4149010D14
IE: Unknown: 200100
IE: Unknown: 2A0100
IE: Unknown: 32043048606C
IE: Unknown: DD180050F2020101830002A3400027A4000042435E0062322F00
IE: Unknown: DD0900037F01010034FF7F

“dlink” is the essid of my router, whereas “phar0z” is the essid of my own software access point on my server.

I’ve changed my /etc/network/interfaces file on my Linux laptop.

auto lo
iface lo inet loopback

# wireless
iface wlan0 inet dhcp
wireless_essid phar0z
wireless_key A1B3C5D7E0
auto wlan0

Then I ran /etc/init.d/networking restart. And this is the new output of iwconfig wlan0

wlan0 IEEE 802.11abgn ESSID:"phar0z"
Mode:Managed Frequency:2.437 GHz Access Point: 00:17:9A:76:B0:10
Bit Rate=24 Mb/s Tx-Power=15 dBm
Retry min limit:7 RTS thr:off Fragment thr:off
Encryption key:A1B3-C5D7-E0 Security mode:open
Power Management:off
Link Quality=62/70 Signal level=-26 dBm Noise level=-127 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0

Everything is working fine.



Desktop migration to Arch Linux Thursday, Sep 3 2009 

I’ve installed Arch Linux on my desktop. I really like its philosophy and the high level of configurability. After the installation was complete I’ve extended my base system with xorg and kde. This was very easy with a package manager like pacman. I just executed pacman -S xorg kde.Though everything seemed to work I’ve noticed my X-server wasn’t able to handle input from my keyboard or mouse.

I have an nvidia 7600 graphics card and I’ve created my xorg.conf with nvidia-xconfig. Shit, still not any kind of input while the X-server shows up. Building a new xorg.conf with Xorg -configure gives the same result. I was in trouble, but then “let’s try HAL” (=hardware abstraction layer) came into my mind.

I’ve already mentioned the level of high configurability on Arch Linux. It works with a main configuration file, called rc.conf in the /etc directory. I simply added hal to my DAEMONS array.

6 root@archlinux $ cat /etc/rc.conf | grep DAEMONS
DAEMONS=(syslog-ng network netfs cron hal alsa kdm)

And I’ve deciced to combine this with a minimalistic xorg.conf file. Here you can see my /etc/X11/xorg.conf

Section "Device"
Identifier "Device0"
Driver "nvidia"
VendorName "NVIDIA Corporation"

Section "Screen"
Identifier "Screen0"
Device "Device0"
Monitor "Monitor0"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "1280x1024"

Arch Linux is a great Linux distro. I like its philosophy, its principles, pacman (package management), ABS (Arch Build System) …
Whereas my desktop is running Arch, I’m still running Ubuntu on my notebook. Variation is nice. Oh yeah, I’m thinking about moving my server to Arch Linux as well.


Bash script to send attachments with attachments through command line Thursday, Sep 3 2009 

I’ve created a simple script in Bash which can send e-mails with attachment through commandline. You need “mutt” and a working mail system in order to get this working. You need to create a textfile named mailmessage.txt in your home map that includes the text of the mail.

ONDERWERP="With an important attachment"
echo "What's the e-mail of the recipient"
echo "Locate the attachment:"
mutt -s $ONDERWERP -a $ATTACHMENT $EMAILADRES < /home/$USER/mailmessage.txt

I'm using postfix as Mail Tranfer agent. You will notice I'm using Telenet as a relayhost. This is my /etc/postfix/

smtpd_banner = $myhostname ESMTP $mail_name (Postfix & GNU/Linux up and running)
biff = no.
append_dot_mydomain = no
# TLS parameters
smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt
smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key
smtpd_use_tls = yes
smtpd_tls_session_cache_database = btree:${queue_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${queue_directory}/smtp_scache

myhostname = ubuntux
mydomain =
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination =, localhost,, localhost
relayhost =
mynetworks =, 192.168.0.*,
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
myorigin = localhost
inet_protocols = all
smtpd_sasl_local_domain =
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
smtpd_tls_auth_only = no
smtp_use_tls = yes
smtp_tls_note_starttls_offer = yes
smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem
smtpd_tls_loglevel = 1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom
home_mailbox = Maildir/


ath5k + Jaunty + Compat-wireless + self-compiled kernel. Thursday, Sep 3 2009 

How to get ath5k working on Jaunty with Compat-wireless and a self-compiled kernel

I used to have some trouble while setting up my Atheros PCI card on Ubuntu Linux 9.04. It worked natively on Ubuntu 8.04, where it was detected as ath0. I upgraded from 8.04 to 8.10 whereby I noticed my wireless PCI card didn’t work natively anymore. Someone suggested me to upgrade from 8.10 to 9.04 Jaunty, and I did that immediately. After the system upgrade I noticed again that my wireless device was gone in Ubuntu 9.04. When I ran iwconfig I didn’t see wlan0 or ath0 anymore.
Here you can see some details of my PCI card:

7 root@linux $ lspci | grep Atheros
04:00.0 Ethernet controller: Atheros Communications Inc. AR242x 802.11abg Wireless PCI Express Adapter (rev 01)

Now I’ll confirm that I’m running Ubuntu 9.04 Jaunty:

8 root@linux $ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 9.04
Release: 9.04
Codename: jaunty

In the beginning I only saw the following on Jaunty. Here you can see that a wireless device doesn’t show up.

24 root@linux $ iwconfig
lo no wireless extensions
eth0 no wireless extensions
pan0 no wireless extensions
wmaster0 no wireless extensions.

I’ve tried stuff like madwifi, ndiswrapper and previous modules like ath_pci . None of them was able to fix my problem, the wireless device was still missing.

Then I’ve heard that I need the ath5k FOSS Linux Wireless driver, something that is provided by the compat-wireless package.

I downloaded a compat-wireless tarball from but I was unable to get it working. While compiling I received several errors, one of these errors reported something like “You need to have mac 08211 enabled in your kernel …”. After trying different versions of the compat-wireless tarball on the Ubuntu Generic kernel I realized that it was impossible to compile this on a default Ubuntu generic kernel.

So you have to compile your own kernel. While I’m writing this tutorial I see that is the latest version of the Linux kernel. Keep in mind that this version might be old now, so is the wget link. Start a konsole/terminal and enter this as root:

cd /usr/src
tar xjf
ln -s linux- linux
cd linux
make clean && make mrproper

cp /boot/config-`uname -r` ./.config

You must first enable mac80211 in order to enable ath5k!

Now as root, run: (You still have to be in /usr/src/linux)

make menuconfig

You can eventually load your alternate configuration file, but this isn’t compulsory. Now you have to commit some very important changes. Use your arrow keys to navigate:

Networking —>
Wireless —>
Improved wireless configuration API
M Generic IEEE 802.11 Networking Stack (mac80211)
Make sure that you see the “M” like above. Now you’ve enabled mac80211.

Now you can enable ath5k in the kernel configuration.

Device Drivers —>
[*] Network device support —>
Wireless LAN —>
M Atheros 5xxx wireless cards support
Make sure it looks like this.

Now you’re finished and you simply have to select Exit. You say YES when you the following question appears. (Do you wish to save your new kernel configuration?)

Ok, now you can start with compiling your kernel.
make-kpkg clean
fakeroot make-kpkg –initrd –append-to-version=-mykernel kernel_image kernel_header

Depending on your CPU speed, this will take a certain time. When it’s all finished you have to install your new kernel.

cd /usr/src
dpkg -i linux-image*.deb
dpkg -i linux-headers*.deb

Your GRUB bootloader configuration file should be modified automatically. Make sure that your now kernel entries are visible in your /boot/grub/menu.lst file. If not, you have to insert the necessary lines by modifying your /boot/grub/menu.lst file.

Reboot now, and boot in your new self-compiled kernel.

Download a compat-wireless tarball from Extract the tarball, go into the newly created map and install compat-wireless.

tar jxvf compat-wireless*.tar.bz2 or tar zxvf compat-wireless*.tar.gz
cd compat-wireless*
make && make install
depmod -a

Now you should be able to load the necessary module.

modprobe ath5k

And wow, a wireless device appears while you run iwconfig

Check your /etc/network/interfaces file and restart the service with /etc/init.d/networking restart and it should be working.


A Bash script to download music from youtube Thursday, Sep 3 2009 

Let’s do some stuff …

I’ve written a simple Bash script that downloads music from youtube. After the music has been downloaded by the script, the flv file (Youtube flash format) will be automatically converted to mp3. Of course the script its last task is to remove your .flv file.

The script requires you have youtube-dl and vbrfix. If you don’t already have them, you have to install them with your package manager. I suppose you have a music folder in your /home directory, if this is not the case you can either create one or you can change the script according to your own needs.

# checking whether you have youtube-dl
if [ ! -x `which youtube-dl`  ];then
echo “Error! youtube-dl isn’t installed.”
exit 0

#checking whether you have vbrfix
if [ ! -x `which vbrfix`  ];then
echo “Error! vbrfix isn’t installed.”
exit 0

#download video(s)
for URL in $*; do
youtube-dl -t “$1&fmt=18″

for VIDEO in `ls *.flv`; do
ffmpeg -i $VIDEO -acodec copy $OUTPUT

#move video
mv $OUTPUT /home/$USER/music
vbrfix /home/$USER/music/$OUTPUT /home/$USER/music/$OUTPUT
rm -rf vbrfix.log vbrfix.tmp
rm -rf $VIDEO
echo “Done.”

Save the script as converter. Of course you have to make the script executable by setting the right permissions: chmod a+x converter

If you want to use it: ./converter youtube-link