Weighted wired & wireless network (and ifplugd)

I was looking for a way of preventing me from having to wait for DHCP to timeout when booting with no network cable attached (actually I was looking for the correct parameter to adjust the timeout and make it much less – but the solution I eventually found was much neater). Most of this comes from an article on the CLUG Wiki about roaming between wireless and wired networks.

First of all I installed ifplugd. Under Debian this was easy, I configured eth0 (my inbuilt wired card) as the only static interface, and ath0 (my inbuilt wireless card, using madwifi) as a dynamic interface so I could turn the wireless on and off using ifup and ifdown without it connecting to the network when it was in range without my permission (I’m not paranoid, I know they’re coming to get me ;) ).

# apt-get install ifplugd

I also changed -d10 to -d1 so that the interface goes down 1 second after the cable comes out instead of 10 as suggested on the CLUG Wiki (link above).

I then edited ‘/etc/network/interfaces’ to ensure that no ‘auto’ lines pointed to eth0 or ath0.

Starting ifplugd was then just a case of:

# ifdown eth0
# /etc/init.d/ifplugd restart

The install was tested by unpluging and re-pluging the network cable and listening for the ‘beep’s that ifplugd emits when it detects these changes.

I continued following the instructions on the CLUG Wiki to setup the priorities of the interfaces so that if both a wired and wireless connection were available it would use the wired one in preference to the wireless.

First I installed iproute:

# apt-get install iproute

Next I modified ‘/etc/network/interfaces’ to look like this:

# The loopback network interface
auto lo
iface lo inet loopback# The primary network interface
noauto eth0
iface eth0 inet dhcp
up /usr/local/sbin/route-prios $IFACE 1

# Wireless
noauto ath0
iface ath0 inet dhcp
wireless-essid omitted for security
wireless-key omitted for security
up /usr/local/sbin/route-prios $IFACE 10

Debain, madwifi-ng and module assistant

I installed Debian GNU/Linux on my laptop (over Arch Linux) last week, and used module-assistant to install the Madwifi driver for my atheros-based wireless card using The Debian Way(TM).

Here is just a quick note of the commands needed to install madwifi using module-assistant under Debain GNU/Linux:

# apt-get install madwifi-source madwifi-tools module-assistant
# m-a update
# m-a prepare
# m-a a-i madwifi
# modprobe ath_pci

…and that’s all there is to it. Not quite as easy as ‘emerge madwifi-driver’ or ‘pacman -S madwifi-ng’ but still fairly straight forward.

Hmm, Blog

I recently (re-)discovered I’d actually installed a blog script, and never written anything down! Oh well, no time like the present to start – I wonder how long I will be able to keep writing entries before I:

  1. get bored with the whole ‘blog’ idea
  2. simply forget about or neglect the blog to the point that it disappears from my mind (again!)
  3. I get distracted by some project or other.

I recently managed to set up a Debian-based mail server. I originally searched google and came up with a number of guides to doing this which looked quite good, albeit long but it’s a project I’ve been planning for a while so I decided to bite the bullet and have a go. After installing Debian and playing around with various different approaches for a bit, I discovered an entry on another blog at The Tech Terminal explaining how the author had setup a Debian Mail Server. This simply said that all I had to do was enter this:

# apt-get install courier-imap
# apt-get install postfix
# postconf -e 'home_mailbox = Maildir/'
# postconf -e 'mailbox_command ='
# /etc/init.d/postfix restart

at the command line. This was certainly a lot easier that the 8-page guide I had be following previously, and it worked :).

Using other guides to install spamassassin and squirrelmail and it was all working very nicely. Fetchmail and gotmail were easy to install and configure using the man pages so I didn’t need to enlist google’s help with them. I now have a single server with 2x40GB HDDs (configured for RAID 1 using a PCI PATA RAID card) which goes and fetches emails from my 2 POP accounts and my hotmail account and delivers them to my local user on the machine (for my purposes I decided LDAP was overkill and that dropping the mail to a local user’s Maildir made more sense). This means I can now access my mail using an IMAP client on either my desktop or laptop, or I can use a web-browser from any other location.

One small snag did run into is that Maildir creates a directory for each directory on the server (as you’d expect) but doesn’t nest them. I was expecting them to nest and it took a while (and some head-banging) for me to discover that Maildir actually uses a ‘.’ to represent sub-directories.
e.g. this structure:

: :-Mushroom
: :-Snake

becomes this Maildir structure: