Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Have some troubles with internal mail server and wanting to migrate to external mail provider (pdd.yandex.ru).

I know how to transfer users and their mail (many thanks for API to Yandex), but in current configuration we have one host as pop3/smtp/imap server (mail.ourhost.net) and now we need to work with three different servers - pop/smtp/imap.yandex.ru.

The main question is how to transparently transfer incoming user requests from mail.ourhost.net to pop.yandex.ru, smtp.yandex.ru and imap.yandex.ru depending on port of connection.

Any ideas? Thanks.

share|improve this question
    
What do you have to work with? Can you just forward traffic to the appropriate destination using netfilter as a temporary workaround and migrate users' configurations to the new server names over time? –  the-wabbit Feb 10 '13 at 15:42
    
Yes, i think i can. Thanks. –  alekseygr Feb 10 '13 at 18:00

1 Answer 1

up vote 0 down vote accepted

You put put a machine at mail.outhost.net that relays traffic on the POP3 port to pop.yandex.ru, the IMAP4 port to imap.yandex.ru, and so on.

Turn on IP forwarding (otherwise the kernel will drop redirected packets):

echo 1 >/proc/sys/net/ipv4/ip_forward

Relay port 110 to pop.yandex.ru:

iptables -t nat -A PREROUTING -p tcp --dport 110 -j DNAT --to-destination pop.yandex.ru
iptables -t nat -A POSTROUTING -p tcp -d W --dport 110 -j MASQUERADE

There are a number of problems with this:

  1. You now have a new machine you have to maintain.
  2. The bandwidth to this host is 2x the bandwidth to Yandex's servers. That may be a lot!
  3. You have a single point of failure.
  4. If Yandex changes their IP address (or uses multiple IPs) you will always be chasing Yandex.

If I were to use this technique, I would only use it to find users that haven't changed their configuration yet. Keep good logs of which IP addresses use this service and make sure you track these people down and configure their machines correctly as soon as possible.

I do not recommend using this technique as a permanent solution. If you are so overloaded that your "temporary" solutions often turn into permanent solutions, do not do this at all. Instead, let people be without email for a while as you visit each machine to configure it properly. If Yandex has a web-mail option, they can use that while they wait. Reconfiguring the clients is something that could be automated with PowerShell; you shouldn't actually visit each machine.

For a new configuration, you might consider using hostnames like pop.yourcompany.com and imap.yourcompany.com. Make those CNAMEs to the Yandex servers. If you have a very large company, you might consider creating a CNAME for each user so that pop-madhatter.youcompany.com is a CNAME that can be pointed at any particular server. In the future you'll be able to move users one at a time.

share|improve this answer
    
Thanks for your solution. I will think about using it as temporary, before all of my users don't change their client configurations. –  alekseygr Feb 10 '13 at 18:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.