Sunday, February 1, 2009

OpenWRT mailserver

Just finished getting my WL500gp to work as a mail server. Features so far:
  • Secure IMAP (using SSL)
  • SMTP server (receive mail for my domain, forward local mail to provider's smtp server (smart host))
  • Assus WL500G premium
  • OpenWRT Kamikaze 7.09
  • PC with linux (kubuntu)
  • NAS for storage
  • Free server SSL certificate from
What I did:
  • Install OpenWRT (Kamikaze 7.09 release)
  • Install OpenWRT packages (ipkg) for nfs
  • Get NFS to work, so i can mount filesystems on my NAS, I mount /var/mail from there. (Also put a swap file on the NAS disk, mouted using -o loop, since I expect that with all services running that I (eventually) want, peak memory usage could easily exceed the 32MB my router has installed)
  • Install dovecot (ipkg), and configure it (using my SSL server certificate)
  • I didn't find a ready-to-use package for a smtp server, so had to build one myself.
I decided to go for exim, since I hae experience with it, it is flexible, and performance/resource usage seems to be within limits (according to articles on the net). Cross compiling it was not trivial, though. Either I could try to get a generic cross-compiling setup on my linux pc and try to compile exim there. Or I try to use the OpenWRT build tools. I used the last approach.

Using these instructions I managed to build an exim package, but only after many trial-and-error patching of makefiles. An annoying thing is that exim builds an executable that generates a config.h file and this executable needs to be built to run on the host (linux pc), not on the target (wl500gp). I finally got it working, at least on my system (I took a pragmatic approach, and didn't spend the time to figure out what the 'right' way would be to accomplish things like calling the host compiler in stead of the cross compiler).
The resulting package description can be found here. It needs the gdbm and openssl packages installed.

Next items on my wish list are:
  • run fetchmail for getting mail from accounts that don't support forwarding (should be easy, since a fetchmail ipkg is available)
  • add a webmail interface (https)

No comments: