Manually Adding A Domain By Setting Up DNS Records At Cloudflare

Greetings Mail-in-a-Box world!

I am brand new to Mail-in-a-Box.

Most of my domains are registered at Cloudflare.

Cloudflare does not allow you to change your nameservers like many other registrars do.

I want to add a couple of additional domains to my Mail-in-a-Box setup, but I cannot use the option of setting the nameservers and letting Mail-in-a-Box do the DNS setup.

Basically, I will need to add all of the necessary dns records manually inside of Cloudflare.

Everything I searched for in this group only told me about the change-the-nameserver method.

Is there a tutorial or document anywhere that shows every dns record that I would need to add manually to make this work?

Thanks in advance for your help!

1 Like

JonD, I am happy you chose Mail In A Box to self host your mail server.

Like you, I too have my domains registered on Cloudflare. I would like to advice you that Cloudflare allows you to delegate a sub domain to name servers hosted by Mail In A Box using the “NS” record.

Let me say my domain name is “EXAMPLE.COM” and so, I create “qwerty.example.com” in CloudFlare dashboard and add two “NS” records and point them to “ns1.box.qwerty.example.com” and “ns2.box.qwerty.example.com”.

Now, I make a stub “ns1.box.qwerty.example.com” with an A and AAAA record to the appropriate IP address. Likewise for “ns2.box.qwerty.example.com”.

Now, I run the Mail In A Box setup and my box is setup and I will have a personal email address me@qwerty.example.com.

I am using sub domain “qwerty.example.com” and if I want to allow mail for the root domain, “example.com”, I can setup Email forwarding with CloudFlare to forward all email to @example.com to the Mail In A Box account, me@qwerty.example.com.

If you have more than one domain in CloudFlare just create a sub domain name for each domain that you want to setup Mail In A Box on and delegate it to two name servers that will host your Mail In A Box.

This works not only on CloudFlare DNS but also NameCheap DNS. Both registrars allow free email forwarding.

Its very easy :slight_smile:

JonD, I hope you can understand but if you still do not please tell me what you do not understand so I can try to help you.

2 Likes

How to setup miab with Cloudflare is discussed here. You need to use the external dns option and manually copy the values that miab suggests to Cloudflare

Thanks @sugumaranv .

I didn’t know you could do that at Cloudflare.

Although, it is a bummer that you would need that subdomain in the email address.

I actually went through and manually added a bunch of DNS records in Cloudflare and successfully added another domain to my MailInABox setup!

Although it was onerous to have to add all of those.

Also, I am not a DNS expert, so there was some scary guesswork, but apparently I guessed right.

It would be nice if there was a way inside MailInABox to “add a domain” and then get a list of the precise DNS records you need to add to your domain.

Or a good tutorial haha.

1 Like

@eXTric

Thanks for chiming in!

Are you talking about the glue records?

Or is there a place where MIAB lists suggested DNS records somewhere?

P.S. I am NOT talking about the MAIN domain for the MIAB setup, just additional domains.

You go to system > external DNS.
MiaB creates a zone file for every domain you created an email for (which is how you add a domain)
The zone file can not be imported to Cloudflare so you need manually copy the values.
When i was warming up my IP and testing miab I had two domain at Cloudflare and you need to do the procedure for each domain.

1 Like

This is tedious process to add every record manually.

I use CloudFlare as my registrar, and I create a sub domain, miab.example.com with two NS records:
ns1.box.miab.example.com
ns2.box.miab.example.com

Then, I setup a glue record for both ns1 and ns2 to the appropriate IP number.

Finally, I run the MIAB setup and the system installs itself.

Of course, I will like all email to @example.com be forward to me@miab.example.com, and CloudFlare gives free email routing.

1 Like

@eXTric

Do you do all the optional DNS Records?

Yes i did. Just make sure you have a way to keep track of what you already copied.
It is a pain but if you do it right you only need to invest time in it once.

1 Like

@eXTric

I’ve had success with two additional domains now and all seems good.

I did notice that on the external DNS instructions inside MailInABox there were a couple of these type situations:

autoconfig.myaddondomain.com MX 0

Only Cloudflare required a mail server, so I put in my box.myfirstdomain.com address because the MailInABox instructions seemed to want to leave the mail server BLANK.

I am curious, did you handle that differently, or did you do the same thing?

This seems awfully convoluted. I would not do it this way. However, that said, I would still point the NS for the MiaB subdomain to the MiaB itself, but all of the domains that are hosted on the box, I would manually enter the required DNS records to CF. Then there is no need to do this convoluted forwarding regimen.

Did you miss the period in the value field? There is a period there that you enter. This tells DNS that there is no mail server for the (sub)domain.

image

1 Like

There is … on the External DNS page you can download a copy of the zone file.

image

1 Like

@alento

Oh! I had no idea that is what the “.” meant.

I’ll have to go and try that out.

@alento

I tried that.

When I tried to upload it to Cloudflare there was some kind of error and nothing imported.

I tried several times and then just reverted to manually doing it.

@eXTric @alento @sugumaranv

How do y’all handle dnssec ?

I see that when a domain is registered at Cloudflare, when you click on the button to activate dnssec, Cloudfare automatically sets it up on their end with their own dnssec settings.

So, of course, those don’t match what MailInABox requires.

Do you just leave dnssec off?

Or maybe there is something I am missing?

This is officially my first project where I am dealing with dnssec at all on my own.

JonD, as I use a sub domain that I delegate exclusively to MIAB name servers, so, DNSSEC works perfectly for me.

My email address will be me@miab.example.com. As I mentioned earlier, I use CloudFlare Email Routing that forwards every email to *@example.com to me@miab.example.com.

There is always a workaround.

1 Like

@sugumaranv

I haven’t decided about that route yet, although I am glad to know about it.

I did have a follow up question about what you said earlier on that.

What does it mean to “make a stub” in this context?

I am not familiar with that phrase (although I am reading about it having googled it).

Also, the example you gave is of an add on domain, right? Not the main MAIB domain?

Why do you need to add the “box.” in that case (being only an addon domain)?

By “stub”, I mean a “glue record” for the sub domain.

As CloudFlare does not allow changing DNS servers, so suppose a domain name is EXAMPLE.COM, you just add a sub domain, like MIAB.EXAMPLE.COM, and then add an NS record for it with value “ns1.box.miab.example.com”. Do the same for “ns2.box.miab.example.com”.

Then make sure you set an A or AAAA record for both ns1.box.miab.example.com and ns2.box.miab.example.com" as they are stub or glue record for your sub domain.

Yes, its like being your own registrar :slight_smile:

MIAB is really fun as it empowers you.

2 Likes

@sugumaranv

Why include the “box” in the “stub?”

At least, why if I am setting up an addon domain rather than the main domain?