Categories
dovecot IMAP iptables Linux nat notepad redirect

You want the other server, really…

In my last post I talked a bit about my server loop dependancies. Well one way to break that was to shift the e-mail processing and dovevot (imap) server from one machine to another.

Shifting the e-mail was easily done. I just installed the software, copied over the configuration files to the new server and started it. dovecot was just as simple. But now I needed to shift all my users to the new imap server. Keeping two dovecot servers going wasn’t the solution so I began to hunt for ways to redirect imap connections to the new server.

I looked at http://www.dovecot.org/ for a solution. Dovecot can redirect users but this is not guaranteed to work and it involves setting up MySQL – which is a database I am not familiar with.

A lightbulb then popped into my head – why not get the old server to redirect the TCP connections to the new server! All Linux boxes have routing capability built in via a kernal flag and the iptables service. Iptables are normally used for firewalls, typically setup using UFW. But iptables also has a nat capability and can redirect packets to another server.

After a bit of looking I determined that the following command would do the trick

sudo iptables -t nat -D PREROUTING -p tcp --dport 143 -j DNAT --to-destination 192.168.1.227:143

And this does just what’s needed. The clients don’t even realise what’s going on a each packet is re-written with the new destination. I’ve found that this does not create a load on the old server at all as after the initial connection sequence all packets appear to be going to the new server directly.

Now I can go to each client machines and gradually over time change the name of the machine in their connection setup.

Has anybody ever noticed that notepad on very rare occaisions hangs when saving a file? Here’s a tip. Do not kill the process. Let it sit.  This will probably take about 2-3 minutes. The file save dialog will popup and you can save as usual.

My theory on this is that presumably the last file I saved was to a network connection which now doesn’t exist or is not responding. So Notepad is trying access that connection again and is waiting for it to timeout. EIther that or there is a registry issue, I have also heard that some anti-virus packages can interfere.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.