How to setup, with mutliple domains per VPS

September 11, 2014 3.4k views


I want to setup this:
VPS 1: hostname
VPS 2: hostname

On both VPS-es I want to host like maximum 5 websites.
For all the websites I want mailserver per site. Like mailserver hostname is: and for the second website on VPS 1 it would be

I know how to setup a VPS with mutliple domains (done this using VirtualMin), but how to set up multiple VPS-es where the hostname is a subdomain / hostname of my purchased domain (srv1. or srv2, etc.). How would I setup mail correctly per server?

I now was thinking about this as DNS for points to Droplet 1 (A record) points to Droplet 2 (A record)

In DOs DNS manager I have set-up a add a new website for every website on srvX. The A records of this website redirects to either VPS1 or VPS2 depending on what srvX the website is on.

This seems to work, but now: how to setup mail? (just the DNS settings, I already set up mailservers with postfix and dovecot)

Should I just add per website, which points to a specific VPS?
Because I have read that the VPS name has to be the mailserver name for the PTR record to setup correctly. That would make it impossible to add multiple mail.websiteX records?


1 Answer

On DO environment you have many ways to do this... but I list two

you need to choose the default VPS-es domain...
Pratic example



When you rename your vps to this names automatically this point to your vps IP, this is PTR record PTR PTR

When you create DNS records for domains like: MX 5 MX 5 MX 5 MX 5 MX 5

AND TXT SPF records you use something like "v=spf1 mx ~all"
this allow vps1 hosts to send mail for your domains.
Are necessary? Not, but prevents that messages will be marked as spam.

Other way to do this are: MX 5 MX 5 MX 5 mail.domain3com MX 5 MX 5

And yours respectives "A" records
and TXT SPF record something like "v=spf1 ~all" or "v=spf1 ~all"

A think thats help you!


  • Awesome, thanks a lot for this. I think I got it and I must get it working using this.

    Two questions more though:

    1. For the first option, what would my mailserver be for example to use in a mailclient? Because there are no A records for, etc?
    2. Lets say I have domainname ''. I have 2 VPS-es, and At the domain registar for '', should I just create 2 A records for VPS1 and VPS2 and point those to the droplets IP`s for vps1 and vps2? Actually, at the moment I already have a droplet for '', which droplet name is already So I would add a DNS record to that droplet like A XX.XX.XX right?

    Because in your situation (in your text is actually a domain on In my situation is a droplet for itself, with its own records. (which is working). So could this remain, or should I rename this droplet to

    Thanks a lot.

  • Right,

    On the first option (i think that is your choice) so you can do something like this, look: IN A IN A

    on DO painel, you rename your VPS-es to
    and this will create PTR records on DO name servers like IN PTR IN PTR

    for each domain you can create. IN A IN MX IN TXT "v=spf1 ~all" IN CNAME IN CNAME

    Right? :)

    Best regards

  • Awesome. I`m going to set it up like this. Thanks a lot.

  • Hi,

    I have set this up following your description and it is working flawless!

    Only thing is I needed to add an A record for else my outgoing mailserver would not work using It did work using as mailserver. Incoming does work for without the A record (with just the cname record).

    Thanks anyway for your help!

  • Hi,

    The e-mail is working, but we receive a lot of messages that mails are not reaching us. No error message or something, maisl just are not delivered. Also, lots of mails we sent are delivered to spambox of the user.

    I have setup a mainserver in virtaualmin. The domain we e-mail from is a subserver (can this be the reason why it is not working?)

    The subserver has a mx 5 record to the mainserver and an txt record. Also an A record to the IP of the server for mail.subserver.

    The mainserver has no mx or txt records. Can it go wrong there? Because the subserver points to the mainserver and the mainserver has nog Mx record? I don`t know how this works exactly. If the subservers mx records points to the mainservers hostname, would the mainserver need Mx and txt records too?


Have another answer? Share your knowledge.