How To Set Up a Host Name with DigitalOcean


Before you get started, you do need to have the following:

  • A Droplet (virtual private server) from DigitalOcean. If you don’t have one, you can register and set one up in under a minute
  • A Registered Domain Name. As of yet, you cannot register a domain through DigitalOcean.

Step One—Look Up Information with WHOIS

The first thing you need to do to set up your host name is to change your domain name server to point to the DigitalOcean name servers. You can do this through your domain registrar’s website. If you do not remember where you registered your name, you can look it up using “WHOIS”, a protocol that displays a site’s identifying information, such as the IP address and registration details.

Open up the command line and type:


WHOIS will display all of the details associated with the site, includng the Technical Contact which includes your domain registrar.

Step Two—Change Your Domain Server

Access the control panel of your domain registrar and find the fields called “Domain Name Server.” The forms for my domain registrar looked like this

Point your name servers to DigitalOcean and fill in three Domain Name Server fields. Once done, save your changes and exit.

The DigitalOcean domain servers are


You can verify that the new name servers are registered by running WHOIS again; the output should include the updated information:

Domain Name: EXAMPLE.COM
   Registrar: ENOM, INC.
   Whois Server:
   Referral URL:
   Status: ok

Although the name servers are visible through WHOIS, it may take an hour or two for the changes to be reflected on your site.

Step Three—Configure your Domain

Now we need move into the DigitalOcean control panel.

Within the Networking section, click on Add Domain, and fill in the the domain name field and IP address of the server you want to connect it to on the subsequent page. Note: The domain name does not have a www at the beginning.

add a domain

You will reach a page where you can enter all of your site details. To make a new hostname, you only need to fill in the A record. If you are using an IPv6 address, you should enter it into the AAAA record.

A Records: Use this space to enter in the IP address of the droplet that you want to host your domain name on and the host name itself, a name prepended to your domain name. For example:

To accomplish this, create a new hostname with the word “test” in the hostname field. Your screen should look like this:

domain name

Save by clicking “Add new A record”

You can also connect your IP to a domain name with nothing before it (this should also occur by default when you add a domain):

To accomplish this, create a new hostname with the symbol “@’ in the hostname field. Your screen should look like this:

domain name

You can save by pressing enter after making the required changes on the line.

AAAA Records: Use this space to enter in the IPv6 address of the droplet that you want to host your domain name on and the host name itself, a name prepended to your domain name or you can also connect your IP to a domain name with nothing before it. To accomplish this, create a new hostname with the symbol “@’ in the hostname field. Your screen should look like this:

For example:

domain name

Save by clicking “Create”

CNAME Records: The CNAME record works as an alias of the A Record, pointing a subdomain to an A record— if an A Record’s IP address changes, the CNAME will follow to the new address. To prepend www to your URL, click on “Add a new CNAME record” and fill out the 2 fields.

Your screen should look like this:

 CNAME records

You can also set up a catchall or wildcard CNAME record that will direct any subdomain to the designated A record (for example, if a visitor accidentally types in wwww instead of www). This can be accomplish with an asterisk in the CNAME name field.

Your screen should look like this:

catch all CNAME records

If you need to set up a mail server on your domain, you can do so in the MX Records.

MX Records: The MX Records fields should be filled in with the hostname and priority of your mail server, a value designating the order in which the mail servers should be attempted to be reached. Records always end with a “.”A generic MX record looks something like this:

Below is an example of MX records set up for a domain that uses google mail servers (note the period at the end of each record):

Google MX records

Finish Up

Once you have filled in all of the required fields, your information will take a while to propagate, and the Name Server information will be automatically filled in. Your domain name name should be up and supported in a few hours.

You can confirm, after some time has passed, that the new host name has been registered by pinging it:


You should see something like:

# ping
PING ( 56(84) bytes of data.
64 bytes from icmp_req=1 ttl=63 time=1.47 ms
64 bytes from icmp_req=2 ttl=63 time=0.674 ms

You should also be able to access the site in the browser.

How To Install and Setup Postfix on Ubuntu 14.04


Postfix is a very popular open source Mail Transfer Agent (MTA) that can be used to route and deliver email on a Linux system. It is estimated that around 25% of public mail servers on the internet run Postfix.

In this guide, we’ll teach you how to get up and running quickly with Postfix on an Ubuntu 14.04 server.


In order to follow this guide, you should have a Fully Qualified Domain Name pointed at your Ubuntu 14.04 server. You can find help on setting up your domain name with DigitalOcean by clicking here.

Install the Software

The installation process of Postfix on Ubuntu 14.04 is easy because the software is in Ubuntu’s default package repositories.

Since this is our first operation with apt in this session, we’re going to update our local package index and then install the Postfix package:

sudo apt-get update
sudo apt-get install postfix

You will be asked what type of mail configuration you want to have for your server. For our purposes, we’re going to choose “Internet Site” because the description is the best match for our server.

Next, you will be asked for the Fully Qualified Domain Name (FQDN) for your server. This is your full domain name (like Technically, a FQDN is required to end with a dot, but Postfix does not need this. So we can just enter it like:

The software will now be configured using the settings you provided. This takes care of the installation, but we still have to configure other items that we were not prompted for during installation.

Configure Postfix

We are going to need to change some basic settings in the main Postfix configuration file.

Begin by opening this file with root privileges in your text editor:

sudo nano /etc/postfix/

First, we need to find the myhostname parameter. During the configuration, the FQDN we selected was added to the mydestination parameter, but myhostname remained set to localhost. We want to point this to our FQDN too:

myhostname =

If you would like to configuring mail to be forwarded to other domains or wish to deliver to addresses that don’t map 1-to-1 with system accounts, we can remove the alias_maps parameter and replace it withvirtual_alias_maps. We would then need to change the location of the hash to/etc/postfix/virtual:

virtual_alias_maps = hash:/etc/postfix/virtual

As we said above, the mydestination parameter has been modified with the FQDN you entered during installation. This parameter holds any domains that this installation of Postfix is going to be responsible for. It is configured for the FQDN and the localhost.

One important parameter to mention is the mynetworks parameter. This defines the computers that are able to use this mail server. It should be set to local only ( and the other representations). Modifying this to allow other hosts to use this is a huge vulnerability that can lead to extreme cases of spam.

To be clear, the line should be set like this. This should be set automatically, but double check the value in your file:

mynetworks = [::ffff:]/104 [::1]/128

Configure Additional Email Addresses

We can configure additional email addresses by creating aliases. These aliases can be used to deliver mail to other user accounts on the system.

If you wish to utilize this functionality, make sure that you configured the virtual_alias_maps directive like we demonstrated above. We will use this file to configure our address mappings. Create the file by typing:

sudo nano /etc/postfix/virtual

In this file, you can specify emails that you wish to create on the left-hand side, and username to deliver the mail to on the right-hand side, like this: username1

For our installation, we’re going to create a few email addresses and route them to some user accounts. We can also set up certain addresses to forward to multiple accounts by using a comma-separated list:        demouser   demouser        root     demouser,root

Save and close the file when you are finished.

Now, we can implement our mapping by calling this command:

sudo postmap /etc/postfix/virtual

Now, we can reload our service to read our changes:

sudo service postfix restart

Test your Configuration

You can test that your server can receive and route mail correctly by sending mail from your regular email address to one of your user accounts on the server or one of the aliases you set up.

Once you send an email to:

You should get mail delivered to a file that matches the delivery username in /var/mail. For instance, we could read this message by looking at this file:

nano /var/mail/demouser

This will contain all of the email messages, including the headers, in one big file. If you want to consume your email in a more friendly way, you might want to install a few helper programs:

sudo apt-get install mailutils

This will give you access to the mail program that you can use to check your inbox:


This will give you an interface to interact with your mail.


You should now have basic email functionality configured on your server.

It is important to secure your server and make sure that Postfix is not configured as an open relay. Mail servers are heavily targeted by attackers because they can send out massive amounts of spam email, so be sure to set up a firewall and implement other security measures to protect your server. You can learn about some security options here.

How To Run Your Own Mail Server

When setting up a web site or application under your own domain, it is likely that you will also want a mail server to handle the domain’s incoming and outgoing email. While it is possible to run your own mail server, it is often not the best option for a variety of reasons.

A typical mail server consists of many software components that provide a specific function. Each component must be configured and tuned to work nicely together and provide a fully-functioning mail server. Because they have so many moving parts, mail servers can become complex and difficult to set up.

Here is a list of required components in a mail server:

  • Mail Transfer Agent
  • Mail Delivery Agent
  • IMAP and/or POP3 Server

In addition to the the required components, you will probably want to add these components:

  • Spam Filter
  • AntiVirus
  • Webmail

While some software packages include the functionality of multiple components, the choice of each component is often left up to you. In addition to the software components, mail servers need a domain name, the appropriate DNS records, and an SSL certificate.

Let’s take a look at each component in more detail.

Mail Transfer Agent

A Mail Transfer Agent (MTA), which handles Simple Mail Transfer Protocol (SMTP) traffic, has two responsibilities:

  1. To send mail from your users to an external MTA (another mail server)
  2. To receive mail from an external MTA

Examples of MTA software: Postfix, Exim, and Sendmail.

Mail Delivery Agent

A Mail Delivery Agent (MDA), which is sometimes referred to as the Local Delivery Agent (LDA), retrieves mail from a MTA and places it in the appropriate mail user’s mailbox.

There are a variety of mailbox formats, such as mbox and Maildir. Each MDA supports specific mailbox formats. The choice of mailbox format determines how the messages are actually stored on the mail server which, in turn, affects disk usage and mailbox access performance.

Examples of MDA software: Postfix and Dovecot.

IMAP and/or POP3 Server

IMAP and POP3 are protocols that are used by mail clients, i.e. any software that is used to read email, for mail retrieval. Each protocol has its own intricacies but we will highlight some key differences here.

IMAP is the more complex protocol that allows, among other things, multiple clients to connect to an individual mailbox simultaneously. The email messages are copied to the client, and the original message is left on the mail server.

POP3 is simpler, and moves email messages to the mail client’s computer, typically the user’s local computer, by default.

Examples of software that provide IMAP and/or POP3 server functionality: Courier, Dovecot, Zimbra.

Spam Filter

The purpose of a spam filter is to reduce the amount of incoming spam, or junk mail, that reaches user’s mailboxes. Spam filters accomplish this by applying spam detection rules–which consider a variety of factors such as the server that sent the message, the message content, and so forth–to incoming mail. If a message’s “spam level” reaches a certain threshold, it is marked and treated as spam.

Spam filters can also be applied to outgoing mail. This can be useful if a user’s mail account is compromised, to reduce the amount of spam that can be sent using your mail server.

SpamAssassin is a popular open source spam filter.


Antivirus is used to detect viruses, trojans, malware, and other threats in incoming and outgoing mail. ClamAV is a popular open source antivirus engine.


Many users expect their email service to provide webmail access. Webmail, in the context of running a mail server, is basically mail client that can be accessed by users via a web browser–Gmail is probably the most well-known example of this. The webmail component, which requires a web server such as Nginx or Apache, can run on the mail server itself.

Examples of software that provide webmail functionality: Roundcube and Citadel.

Now that you are familiar with the mail server components that you have to install and configure, let’s look at why maintenance can become overly time-consuming. There are the obvious maintenance tasks, such as continuously keeping your antivirus and spam filtering rules, and all of the mail server components up to date, but there are some other things you might have not thought of.

Staying Off Blacklists

Another challenge with maintaining a mail server is keeping your server off of the various blacklists, also known as DNSBL, blocklists, or blackhole lists. These lists contain the IP addresses of mail servers that were reported to send spam or junk mail (or for having improperly configured DNS records). Many mail servers subscribe to one or more of these blacklists, and filter incoming messages based on whether the mail server that sent the messages is on the list(s). If your mail server gets listed, your outgoing messages may be filtered and discarded before they reach their intended recipients.

If your mail server gets blacklisted, it is often possible to get it unlisted (or removed from the blacklist). You will want to determine the reason for being blacklisted, and resolve the issue. After this, you will want to look up the blacklist removal process for the particular list that your mail server is on, and follow it.

Troubleshooting is Difficult

Although most people use email every day, it is easy to overlook the fact that it is a complex system can be difficult to troubleshoot. For example, if your sent messages are not being received, where do you start to resolve the issue? The issue could be caused by a misconfiguration in one of the many mail server components, such as a poorly tuned outgoing spam filter, or by an external problem, such as being on a blacklist.

Now here are some alternatives to running your own mail server . These mail services will probably meet your needs, and will allow you and your applications to send and receive email from your own domain.

This list doesn’t include every mail service; there are many out there, each with their own features and prices. Be sure to choose the one that has the features that you need, at a price that you want.

Easy Alternatives — Postfix for Outgoing Mail

If you simply need to send outgoing mail from an application on your server, you don’t need to set up a complete mail server. You can set up a simple Mail Transfer Agent (MTA) such as Postfix.

You then can configure your application to use sendmail, on your server, as the mail transport for its outgoing messages.