# Multiple domains in Mail-in-a-Box / with the domains being hosted elsewhere?

**URL:** <https://discourse.mailinabox.email/t/multiple-domains-in-mail-in-a-box-with-the-domains-being-hosted-elsewhere/56>\
**Category:** Help with Setup/Upgrade\
**Created:** [September 13, 2014, 6:39pm UTC](https://discourse.mailinabox.email/t/multiple-domains-in-mail-in-a-box-with-the-domains-being-hosted-elsewhere/56 "2014-09-13T18:39:56Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![pryley](https://discourse.mailinabox.email/letter_avatar_proxy/v4/letter/p/f14d63/32.png) [@pryley](https://discourse.mailinabox.email/u/pryley)\
**Post date:** [September 13, 2014, 6:39pm UTC](https://discourse.mailinabox.email/t/multiple-domains-in-mail-in-a-box-with-the-domains-being-hosted-elsewhere/56/1 "2014-09-13T18:39:57Z")

</div>

I’m not sure that I quite understand being able to add multiple domains to the mail-in-a-box server.

Is the following kind of setup possible using Mail-in-a-Box?

Using DigitalOcean, 4 droplets:

**[mailserver.com](http://mailserver.com) (IP: 188.22.10.10 - dedicated mail-in-a-box server)**  
→ [hello@mailserver.com](mailto:hello@mailserver.com)  
→ [hello@domain1.com](mailto:hello@domain1.com)  
→ [hello@domain2.com](mailto:hello@domain2.com)  
→ [hello@domain3.com](mailto:hello@domain3.com)

**[domain1.com](http://domain1.com) (IP: 138.52.11.33 - Ecommerce website with it’s own SSL)**  
→ hosted website 1

**[domain2.com](http://domain2.com) (IP: 138.54.98.101 - Wordpress website)**  
→ hosted website 2

**[domain3.com](http://domain3.com) (IP: 165.71.144.54 - Some other website)**  
→ hosted website 3

---

<div class="post-metadata">

**Author:** ![JoshData](https://discourse.mailinabox.email/user_avatar/discourse.mailinabox.email/joshdata/32/2153_2.png) [@JoshData](https://discourse.mailinabox.email/u/JoshData)\
**Post date:** [September 14, 2014, 3:05pm UTC](https://discourse.mailinabox.email/t/multiple-domains-in-mail-in-a-box-with-the-domains-being-hosted-elsewhere/56/2 "2014-09-14T15:05:39Z")

</div>

Yes, but you’ll have to use the box’s DNS API at the end to set different “A” records for the three other domains. (They default to the box’s IP address.)

---

<div class="post-metadata">

**Author:** ![pryley](https://discourse.mailinabox.email/letter_avatar_proxy/v4/letter/p/f14d63/32.png) [@pryley](https://discourse.mailinabox.email/u/pryley)\
**Post date:** [September 15, 2014, 8:44am UTC](https://discourse.mailinabox.email/t/multiple-domains-in-mail-in-a-box-with-the-domains-being-hosted-elsewhere/56/3 "2014-09-15T08:44:01Z")

</div>

So…

1. All domains must have the nameservers of **[mailserver.com](http://mailserver.com)**
2. **[mailserver.com](http://mailserver.com)** has 3 A records that map the hostnames of each of the other three domains to their corresponding IP address (in order to serve websites for those domains).
3. Mail accounts for each domain are created **[mailserver.com](http://mailserver.com)**
4. Done

Does this cover everything?

---

<div class="post-metadata">

**Author:** ![JoshData](https://discourse.mailinabox.email/user_avatar/discourse.mailinabox.email/joshdata/32/2153_2.png) [@JoshData](https://discourse.mailinabox.email/u/JoshData)\
**Post date:** [September 15, 2014, 9:54am UTC](https://discourse.mailinabox.email/t/multiple-domains-in-mail-in-a-box-with-the-domains-being-hosted-elsewhere/56/4 "2014-09-15T09:54:20Z")

</div>

That should do it…

---

<div class="post-metadata">

**Author:** ![rockman](https://discourse.mailinabox.email/user_avatar/discourse.mailinabox.email/rockman/32/70_2.png) [@rockman](https://discourse.mailinabox.email/u/rockman)\
**Post date:** [January 14, 2015, 10:52pm UTC](https://discourse.mailinabox.email/t/multiple-domains-in-mail-in-a-box-with-the-domains-being-hosted-elsewhere/56/5 "2015-01-14T22:52:02Z")

</div>

What do you mean by using the box’s DNS API? I currently have NS1 and NS2 pointing to my server’s IP and having Mail-in-a-box host DNS. I would like to add a CNAME record to send WWW traffic to a separate web host.

---

<div class="post-metadata">

**Author:** ![JoshData](https://discourse.mailinabox.email/user_avatar/discourse.mailinabox.email/joshdata/32/2153_2.png) [@JoshData](https://discourse.mailinabox.email/u/JoshData)\
**Post date:** [January 14, 2015, 11:03pm UTC](https://discourse.mailinabox.email/t/multiple-domains-in-mail-in-a-box-with-the-domains-being-hosted-elsewhere/56/6 "2015-01-14T23:03:44Z")

</div>

Please see the Custom DNS section in the box’s control panel (/admin).

---

<div class="post-metadata">

**Author:** ![rockman](https://discourse.mailinabox.email/user_avatar/discourse.mailinabox.email/rockman/32/70_2.png) [@rockman](https://discourse.mailinabox.email/u/rockman)\
**Post date:** [January 14, 2015, 11:16pm UTC](https://discourse.mailinabox.email/t/multiple-domains-in-mail-in-a-box-with-the-domains-being-hosted-elsewhere/56/7 "2015-01-14T23:16:31Z")

</div>

Cool. Easy enough. I added the CNAME under Set Custom DNS Records. Is there a manual refresh/restart required? How long until the changes take effect?

---

<div class="post-metadata">

**Author:** ![rockman](https://discourse.mailinabox.email/user_avatar/discourse.mailinabox.email/rockman/32/70_2.png) [@rockman](https://discourse.mailinabox.email/u/rockman)\
**Post date:** [January 15, 2015, 7:12am UTC](https://discourse.mailinabox.email/t/multiple-domains-in-mail-in-a-box-with-the-domains-being-hosted-elsewhere/56/8 "2015-01-15T07:12:51Z")

</div>

It’s been a few hours and I’m not getting redirection to the CNAME of the external host. Advice?

---

<div class="post-metadata">

**Author:** ![JoshData](https://discourse.mailinabox.email/user_avatar/discourse.mailinabox.email/joshdata/32/2153_2.png) [@JoshData](https://discourse.mailinabox.email/u/JoshData)\
**Post date:** [January 15, 2015, 1:01pm UTC](https://discourse.mailinabox.email/t/multiple-domains-in-mail-in-a-box-with-the-domains-being-hosted-elsewhere/56/9 "2015-01-15T13:01:04Z")

</div>

The box starts serving the change immediately. DNS is frequently cached at all sorts of intermediate DNS servers between clients and the box, but those caches typically clear within a few hours.

---

<div class="post-metadata">

**Author:** ![rockman](https://discourse.mailinabox.email/user_avatar/discourse.mailinabox.email/rockman/32/70_2.png) [@rockman](https://discourse.mailinabox.email/u/rockman)\
**Post date:** [January 15, 2015, 5:47pm UTC](https://discourse.mailinabox.email/t/multiple-domains-in-mail-in-a-box-with-the-domains-being-hosted-elsewhere/56/10 "2015-01-15T17:47:11Z")

</div>

whois is showing my nameservers as:  
Name Server: [NS1.mydomain.net](http://NS1.mydomain.net)  
Name Server: [NS2.mydomain.net](http://NS2.mydomain.net)

While the Mail-in-a-box /admin system check indicates the nameserver glue records are correct:  
ns1/ns2.box.mydomain.net

Is there something wrong here?

---

<div class="post-metadata">

**Author:** ![rockman](https://discourse.mailinabox.email/user_avatar/discourse.mailinabox.email/rockman/32/70_2.png) [@rockman](https://discourse.mailinabox.email/u/rockman)\
**Post date:** [January 15, 2015, 6:13pm UTC](https://discourse.mailinabox.email/t/multiple-domains-in-mail-in-a-box-with-the-domains-being-hosted-elsewhere/56/11 "2015-01-15T18:13:09Z")

</div>

Yup, I screwed up. It is fixed now. 😄

---

<div class="post-metadata">

**Author:** ![rockman](https://discourse.mailinabox.email/user_avatar/discourse.mailinabox.email/rockman/32/70_2.png) [@rockman](https://discourse.mailinabox.email/u/rockman)\
**Post date:** [January 16, 2015, 2:42pm UTC](https://discourse.mailinabox.email/t/multiple-domains-in-mail-in-a-box-with-the-domains-being-hosted-elsewhere/56/12 "2015-01-16T14:42:45Z")

</div>

OK, although I fixed my NS glue records, my CNAME configuration still isn’t being served. It’s been over 20 hours. Either I will have to wait even more time for DNS caches to flush or something still isn’t configured correctly. Is there anything else I can verify in my MIAB? Thank you in advance.

---

<div class="post-metadata">

**Author:** ![JoshData](https://discourse.mailinabox.email/user_avatar/discourse.mailinabox.email/joshdata/32/2153_2.png) [@JoshData](https://discourse.mailinabox.email/u/JoshData)\
**Post date:** [January 16, 2015, 2:57pm UTC](https://discourse.mailinabox.email/t/multiple-domains-in-mail-in-a-box-with-the-domains-being-hosted-elsewhere/56/13 "2015-01-16T14:57:45Z")

</div>

To verify- 1) It should be listed in the External DNS tab. 2) You can query from the command line:

```
dig @box.yourdomain.com cname something.yourdomain.com

```

The `@`-parameter is the name or IP address of a DNS server to query, in this case you are checking that the box itself is serving the correct info. And `something.yourdomain.com` is the domain/subdomain that you set the CNAME record for.

---

<div class="post-metadata">

**Author:** ![rockman](https://discourse.mailinabox.email/user_avatar/discourse.mailinabox.email/rockman/32/70_2.png) [@rockman](https://discourse.mailinabox.email/u/rockman)\
**Post date:** [January 16, 2015, 4:41pm UTC](https://discourse.mailinabox.email/t/multiple-domains-in-mail-in-a-box-with-the-domains-being-hosted-elsewhere/56/14 "2015-01-16T16:41:47Z")

</div>

> [@JoshData](#):
>
> To verify- 1) It should be listed in the External DNS tab. 2) You can query from the command line:
> 
> dig @box.yourdomain.com cname [something.yourdomain.com](http://something.yourdomain.com)
> 
> The @-parameter is the name or IP address of a DNS server to query, in this case you are checking that the box itself is serving the correct info. And [something.yourdomain.com](http://something.yourdomain.com) is the domain/subdomain that you set the CNAME record for.

Hey Josh - I just performed this before seeing your response. Great timing. 😄

My Custom DNS is: “[www.thesheehans.net](http://www.thesheehans.net) CNAME [thesheehans.nfshost.com](http://thesheehans.nfshost.com)” which matches the External DNS information tab.

Here’s the output from dig on my box:

```
root@box:~# dig @ns1.box.thesheehans.net www.thesheehans.net all

; <<>> DiG 9.9.5-3ubuntu0.1-Ubuntu <<>> @ns1.box.thesheehans.net www.thesheehans.net all
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 38282
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 3
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.thesheehans.net. IN A

;; ANSWER SECTION:
www.thesheehans.net. 1800 IN A 104.236.128.107

;; AUTHORITY SECTION:
thesheehans.net. 1800 IN NS ns1.box.thesheehans.net.
thesheehans.net. 1800 IN NS ns2.box.thesheehans.net.

;; ADDITIONAL SECTION:
ns1.box.thesheehans.net. 1800 IN A 104.236.128.107
ns2.box.thesheehans.net. 1800 IN A 104.236.128.107

;; Query time: 2 msec
;; SERVER: 104.236.128.107#53(104.236.128.107)
;; WHEN: Fri Jan 16 11:35:24 EST 2015
;; MSG SIZE rcvd: 136

;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 5375
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;all. IN A

;; Query time: 0 msec
;; SERVER: 104.236.128.107#53(104.236.128.107)
;; WHEN: Fri Jan 16 11:35:24 EST 2015
;; MSG SIZE rcvd: 32

```

And querying an external NS:

```
root@box:~# dig @8.8.8.8 www.thesheehans.net all

; <<>> DiG 9.9.5-3ubuntu0.1-Ubuntu <<>> @8.8.8.8 www.thesheehans.net all
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 3544
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;www.thesheehans.net. IN A

;; ANSWER SECTION:
www.thesheehans.net. 1759 IN A 104.236.128.107

;; Query time: 23 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Fri Jan 16 11:39:52 EST 2015
;; MSG SIZE rcvd: 64

;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 62316
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;all. IN A

;; AUTHORITY SECTION:
. 1282 IN SOA a.root-servers.net. nstld.verisign-grs.com. 2015011600 1800 900 604800 86400

;; Query time: 24 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Fri Jan 16 11:39:52 EST 2015
;; MSG SIZE rcvd: 107

```

---

<div class="post-metadata">

**Author:** ![JoshData](https://discourse.mailinabox.email/user_avatar/discourse.mailinabox.email/joshdata/32/2153_2.png) [@JoshData](https://discourse.mailinabox.email/u/JoshData)\
**Post date:** [January 16, 2015, 4:54pm UTC](https://discourse.mailinabox.email/t/multiple-domains-in-mail-in-a-box-with-the-domains-being-hosted-elsewhere/56/15 "2015-01-16T16:54:37Z")

</div>

Ah, I bet the default `A` record for `www` is preventing the CNAME record from being used.

Mail-in-a-Box would need to be modified to not create default `A` records if a `CNAME` record is used.

---

<div class="post-metadata">

**Author:** ![rockman](https://discourse.mailinabox.email/user_avatar/discourse.mailinabox.email/rockman/32/70_2.png) [@rockman](https://discourse.mailinabox.email/u/rockman)\
**Post date:** [January 16, 2015, 4:59pm UTC](https://discourse.mailinabox.email/t/multiple-domains-in-mail-in-a-box-with-the-domains-being-hosted-elsewhere/56/16 "2015-01-16T16:59:57Z")

</div>

> [@JoshData](#):
>
> Ah, I bet the default A record for www is preventing the CNAME record from being used.
> 
> Mail-in-a-Box would need to be modified to not create default A records if a CNAME record is used.

I’m happy to help debug. Can this be fixed?

---

<div class="post-metadata">

**Author:** ![rockman](https://discourse.mailinabox.email/user_avatar/discourse.mailinabox.email/rockman/32/70_2.png) [@rockman](https://discourse.mailinabox.email/u/rockman)\
**Post date:** [January 16, 2015, 6:53pm UTC](https://discourse.mailinabox.email/t/multiple-domains-in-mail-in-a-box-with-the-domains-being-hosted-elsewhere/56/17 "2015-01-16T18:53:41Z")

</div>

> [@rockman](#):
>
> JoshData said:
> 
> Ah, I bet the default A record for www is preventing the CNAME record from being used.  
> Mail-in-a-Box would need to be modified to not create default A records if a CNAME record is used.
> 
> I’m happy to help debug. Can this be fixed?

I attempted to use the DNS API to delete the `A` record for `www`:

```
curl -d " " --user me@mydomain.com:###### https://box.thesheehans.net/admin/dns/set/www.thesheehans.net/a/ __delete__

```

I receive an `OK` response, but the External DNS admin page and `dig @ns1.box.thesheehans.net www.thesheehans.net all` still see the `A` record for `www`. ☹

---

<div class="post-metadata">

**Author:** ![JoshData](https://discourse.mailinabox.email/user_avatar/discourse.mailinabox.email/joshdata/32/2153_2.png) [@JoshData](https://discourse.mailinabox.email/u/JoshData)\
**Post date:** [January 17, 2015, 2:56pm UTC](https://discourse.mailinabox.email/t/multiple-domains-in-mail-in-a-box-with-the-domains-being-hosted-elsewhere/56/18 "2015-01-17T14:56:38Z")

</div>

Yeah, you can’t delete records that you didn’t create.

This will be fixed in the next update. Thanks.

---

<div class="post-metadata">

**Author:** ![byezy](https://discourse.mailinabox.email/letter_avatar_proxy/v4/letter/b/e95f7d/32.png) [@byezy](https://discourse.mailinabox.email/u/byezy)\
**Post date:** [May 17, 2016, 10:11pm UTC](https://discourse.mailinabox.email/t/multiple-domains-in-mail-in-a-box-with-the-domains-being-hosted-elsewhere/56/20 "2016-05-17T22:11:20Z")

</div>

Gday, did this issue ever get resolved? I seem to have the same scenario I have A records and CNAME records for the www subdomains, but the subdomains never resolve correctly.

Any advice much appreciated.  
Cheers!  
Dig:  
dave@webserver:~$ dig @ns1.box.gotany.email www.happygoanna.com.au all  
; \<\<\>\> DiG 9.9.5-3ubuntu0.8-Ubuntu \<\<\>\> @ns1.box.gotany.email www.happygoanna.com.au all  
; (1 server found)  
;; global options: +cmd  
;; Got answer:  
;; -\>\>HEADER\<\<- opcode: QUERY, status: NXDOMAIN, id: 25382  
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1  
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:  
; EDNS: version: 0, flags:; udp: 4096  
;; QUESTION SECTION:  
;www.happygoanna.com.au. IN A

;; ANSWER SECTION:  
www.happygoanna.com.au. 1800 IN CNAME 188.166.238.213.happygoanna.com.au.

;; AUTHORITY SECTION:  
happygoanna.com.au. 1800 IN SOA ns1.box.gotany.email. hostmaster.box.gotany.email. 2016051700 7200 1800 1209600 1800

;; Query time: 2 msec  
;; SERVER: 128.199.224.255#53(128.199.224.255)  
;; WHEN: Tue May 17 18:01:02 EDT 2016  
;; MSG SIZE rcvd: 148

;; Got answer:  
;; -\>\>HEADER\<\<- opcode: QUERY, status: SERVFAIL, id: 40621  
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1  
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:  
; EDNS: version: 0, flags:; udp: 4096  
;; QUESTION SECTION:  
;all. IN A

;; Query time: 0 msec  
;; SERVER: 128.199.224.255#53(128.199.224.255)  
;; WHEN: Tue May 17 18:01:02 EDT 2016  
;; MSG SIZE rcvd: 32

---

<div class="post-metadata">

**Author:** ![bbyford](https://discourse.mailinabox.email/user_avatar/discourse.mailinabox.email/bbyford/32/269_2.png) [@bbyford](https://discourse.mailinabox.email/u/bbyford)\
**Post date:** [March 4, 2017, 2:48pm UTC](https://discourse.mailinabox.email/t/multiple-domains-in-mail-in-a-box-with-the-domains-being-hosted-elsewhere/56/21 "2017-03-04T14:48:52Z")

</div>

Am i right in saying there is still no good guide to setting up a new domain that doesnt involve directing the domains nameserver settings to the box?

I have been successfull with adding multiple domains to my box while hosting the websites for them else by changing the DNS, however it doesnt aways work and it would be great to get a concrete solution to e.g.:

1. I have my main domain [[mysite.com](http://mysite.com)] and i set up my mailinabox with that domain.
2. want to add [name@anotherdomain.com](mailto:name@anotherdomain.com) to my mailinabox setup, what are the steps?!

[Next page](https://discourse.mailinabox.email/t/multiple-domains-in-mail-in-a-box-with-the-domains-being-hosted-elsewhere/56.md?page=2)
