How to Setup Amazon EC2 instance (Ubuntu 14.04), Route 53 and Mail in a Box


I would like to know the complete steps for getting Mail in a Box running. In particular, how to set up the Nameservers.

I have seen the video for Mail in a Box. It shows a Namecheap example.

I have one domain; e.g., This domain handles my website and my emails. I have two servers - one for my website and one for email. The email server has 1GiB. Perhaps I should just purchase a separate domain for email?

Per Amazon:
Adding or Changing Name Servers and Adding or Changing Glue Records

“If you add a name server or change the name of a name server and specify a name that is a subdomain of the domain that you’re updating (for example, in the domain, Amazon Route 53 prompts you to specify one or more IP addresses for the name server. These IP addresses are known as glue records.”

When I added, I was not prompted for an IP address. Can I have a Nameserver record for and another one for

Per Digital Ocean:

“If you do have an active website at your domain, make sure to set up the appropriate additional DNS records on your Mail-in-a-Box server. Otherwise, your domain won’t resolve to your website. You can copy your existing DNS records to make sure everything works the same.”

I am not sure what this message from Digital Ocean means from a practical standpoint; i.e., in terms of the steps I need to take. I have an active website at my domain.

Also, Amazon say to add the following: (for example, in the domain,
Digital Ocean says yourserverip and then NS

It seems the steps are as follows (not for .fi domains):

sudo echo “” > /etc/hostname

sudo nano /etc/hosts
==> localhost.localdomain localhost
==>your_server_ip box
save and close the file

Sign in to the AWS Management Console and open the Amazon Route 53 console at

In the navigation pane, choose Registered Domains.

Choose the name of the domain for which you want to edit settings.

Choose Add/Edit Name Servers.

In the Edit Name Servers dialog box, do the following:

update the fields with,,, and to map: to NS to to NS to

update each of the four glue boxes with yourserverip to map: to yourserverip to yourserverip

see your EC2 instance for your server’s ip. Hint: use an elastic IP.

Wait for Amazon to update the nameservers before you install Mail in a Box. You can confirm the nameservers were updated by using dig, if on Linux.
==>dig MX
==>dig A
==> dig +short

Go to your EC2 instance. Select the security group for your instance. Choose the Inbound tab. Choose edit.
Open ports 22 (SSH), 25 (SMTP), 53 (DNS; must be open for both tcp & udp), 80 (HTTP), 443 (HTTPS), 587 (SMTP submission), 993 (IMAP), 995 (POP) and 4190 (Sieve).

Install Mail in a Box:
==>curl -s | sudo bash