On occasion you may need the ability to redirect SMTP traffic either because an Internet host is down and your mail server is not able to send to the MX record or your client computers need a quick way to send to a new IP without changing the configuration on all email clients. Here's a few examples of what can be done to redirect SMTP traffic.
Mail Server filters or redirects - Condition filters or domain redirects
- Condition filters can be very flexible in how a message is redirected. The condition of a filter can be sender, recipient, IP address, header, or even message body content. If the condition is met then action will be taken to redirect the SMTP traffic. A redirect could be to a different hostname or IP or to a different email address.
- Other types of redirects for mail servers are backup domains. Your mail server likely has options to redirect mail if it's to a particular domain, then perform all the normal scans, such as, Antivirus, Antispam, other filters, and redirect to the backup domains IP address or hostname. This type of redirect is an easy way to redirect an entire incoming domain, which works perfectly for a gateway mail server.
- If you administer your DNS servers you have a lot of control over how client computers resolve SMTP hostnames. Email clients do not resolve recipient domains to an MX record before sending mail, unlike a mail server they send directly to an A record hostname or an IP address. Configuring an email client to use a hostname will give you the ability to change the IP address of the hostname and essentially redirect SMTP at the email client level. For example, let's say your email clients send to mail.your_domain.com and this resolves internally to 192.168.1.8 (your production mail server). If you put up a new mail server on IP 192.168.1.9 you can redirect mail.your_domain.com to 192.168.1.9 using your DNS server giving you global control over all email clients using that hostname. Of course, there's always the problem with DNS cache that prevents this from taking affect immediately, in this case have your clients open a DOS prompt and type ipconfig /flushdns.
- The hosts file is a good way to resolve hostnames on the client computers or the mail server without changing DNS server entries. The hosts file will be used before DNS lookup providing a client side resolver/redirector. This gives you control over individual computers. The hosts file on a windows computer is located in the following directory,
C:\WINDOWS\system32\drivers\etc\
Open the hosts file with any text editor and see the included examples. Please note that this file does not have a file extension - when saving the file make sure there is no extension. As in the above example we can change a few client computers using the hosts file and not affect the entire network. Here's an example hosts file entry,
192.168.1.9 mail.your_domain.com
This can also be done on the mail server computer, however, you need add the MX record and new IP to the hosts file because the mail server will lookup the MX record for delivery instead the the A record. There are lots of different possibilities using the hosts, just keep in mind that your computer will lookup the hostname in the hosts file before looking it up in the DNS server.
Firewall routers are another way to redirect SMTP traffic. Most have the ability to map ports to an internal or external IP. Kerio WinRoute firewall is a good example of a firewall router that will perform this task. What it can do is accept a request for port 25 (default SMTP port) and either translate the port to the requested hostname or map to a predefined hostname or IP. The policies for port mapping can be detailed enough where they only apply to certain IP's or the entire network.
Proxy - Stunnel.
If you are interested in a proxy I'd recommend using Stunnel. It not only provides SMTP redirection it can do it securely. Enjoy!
