shakin’ up noth-ink
Postfix under Windows
The servers here at work run a version of Windows Server. While personally I’m not a fan of running Windows as a server OS, working in a team, means working in a team. Anyway, there is considerable machine and network load with the current infrastructure, which we are fixing. New servers, reorganise the LAN a bit, allocate resources across more machines. All fairly generic. This post is about postfix though.
The current mail server has a per-user license cost and the spam and virus filtering is labour intensive. My preference would be to run Postfix with Spamassasin and ClamAV under Linux, as described (for starters): here and here. Unfortunately, at least in this instance, postifx doesn’t run under Windows. We would like to get away from paying the licensing costs, so I decided to see if I could run postfix and a Windows server concrurrently.
I should probably point out at this junction that I have no idea how high a mail load this option can really work for, nor do I feel like spaming myself to see. If you are running a mail server with thousands of customers then either learn to administer *nix, or, find a mail server that runs under Windows.
QEMU is a generic and open source machine emulator and virtualizer which will run linux as an emulated OS with near native speeds for the physical hardware. So, the plan is: to setup qemu running under Windows and install a guest Linux version and then setup postfix on the guest.
- You can get QEMU for Windows from here. You should also download the kqemu accelerator (note this is a tar.gz file 7-zip or WinRAR are your friends).
- Extract the QEMU zip file to some directory, I used C:\qemu but you can choose anything.
- Extract the accelerator archive and find the kqemu.inf file; right-click it and select install. Note: If you are running Vista (like me on the laptop where I set this up for testing) then this will not work. You need to do some other stuff: Download this inf file and also get this registry fix. Copy the inf file into the kqemu accelerator directory and do the right-click install. Then import the registry fix into your registry. Restart if you feel the need. These fixes come from the QEMU Forum.
- You need to start the kqemu accelerator service before running qemu: net start kqemu will do that. Once again Vista is different. The command is the same but it must be run from a console window acting as administrator. Right-click on the command prompt icon and select “Run as administrator”.
- QEMU is now ready to be used.
- Download any ISO image(s) you need to install the distribution of Linux you want to run.
- Create a disk image: qemu-img.exe create -f qcow2 postfix.img 5G (create a 5G disk with the qcow2 qemu file system).
- To start qemu change to the qemu directory and run: qemu.exe -L . -cdrom C:\qemu\install.iso -boot d -hda postfix.img -net nic,vlan=1 -net user,vlan=1 -kernel-kqemu.
- Work through the install of the selected distribution. You should also now work through the either of the two postfix virtual mail host setups linked above.
- When you have finished installing and are ready to reboot: qemu.exe -L . -hda postfix.img -kernel-kqemu -net nic,vlan=1 -net user,vlan=1 -tcp 25:10.0.2.15:25 – this will forward all incoming connections to the host on port 25 to port 25 on the guest. XP/Vista will ask you to confirm that you want to allow the port to be used make sure you allow it.
That should be it. In all honesty the setup I will be deploying if this path is chosen will probably use SQLite running inside the virtual machine and storing the mail outside via a network share or similiar. Or since there are database servers running on the LAN pointing postfix to them across the network. Do not feel limited to the constraints of the virtual host mail setups.
If you try this please note that the network proxying done by qemu (at least the way described above) only supports TCP and UDP packets. So, for example, you will not be able to ping the outside world, but hey, it’s running under another host os where that will still work.
If you try this out yourself or have some extra ideas to improve performance feel free to leave a comment. If we decide to actually implement this for a live system I will do some benchmarking for performance and write more about it then.
| Print article |
about 3 years ago
Noticed an error with one of the above commands:
qemu.exe -L . -hda postfix.img -kernel-kqemu -net nic,vlan=1 -net user,vlan=1 -tcp 25:10.0.2.15:25
Should read:
qemu.exe -L . -hda postfix.img -kernel-kqemu -net nic,vlan=1 -net user,vlan=1 -redir tcp:25:10.0.2.15:25