Tuesday, December 29, 2009

Create Your Own MX Backup Server

I needed a MX backup server so that i can move my exchange server.
I came up with this:

Download and install Ubuntu server 9.04. (Virtual or hardware)

When the installation is done run:
Code:
sudo -s
Type your root password
Now when you have a root terminal run:
Code:
apt-get update
After the upgrade run:
Code:
apt-get install postfix
Now it is configure time.
Code:
nano /etc/postfix/main.cf
go to the buttom and add in one line:
Code:
smtpd_recipient_restrictions = permit_mynetworks reject_unauth_destination
Then add another line:
Code:
relay_domains = $mydestination domain1.com domain2.net domain3.org
*change domainname to your domains.
And the last line:
Code:
transport_maps = hash:/etc/postfix/transport
Now save the file ctrl + O the exit ctrl + x.

Now we need to create the transport file so run:
Code:
nano /etc/postfix/transport
Enter this to the file:
Code:
domain1.com smtp:mail.domain1.com
domain2.net smtp:mail.domain2.net
domain3.org smtp:mail.domain3.org
*Change to your domains and smtp addresses.
Now save the file ctrl + O the exit ctrl + X.

Now we have to create a binary database for the transport.
Code:
cd /etc/postfix/
then run:
Code:
postmap transport
Now reboot the server or run:
Code:
postfix reload
Good commands to know of:
mailq (List the mail queue)
postsuper -r queueid (sends that mail from the queue)

From a external ip portforward port 25 to this unit.
Now add that external ip to your MX records. (with a higer value than your standard mailserver)
When the main MX record server goes down email will be sent to the backup server.
When the primary server gets back online again postfix will send all mails to the smtp specified in "/etc/postfix/transport".

Try to see that it works.
download mailsend.exe
http://www.muquit.com/muquit/softwar.../mailsend.html
Enter the ip to the backupserver and follow the instructions.
if it works it will relay the mail to your server.