Host multiple domain in one bind server

July 5, 2019 154 views
DNS Debian

Hello

I have an apache2 web server with two virtual hosts
example1.com and example2.com, I also have a dns server and I would like my dns server to be able to resolve the domain name and display website based on the domain name.I have already installed the web server, created the virtual hosts and my dns bind9 server

Thank you.

2 Answers

Hi,

Good job making it this far. BIND is a good choice for DNS software but it is not a trivial exercise, configuring and maintaining your own DNS infrastructure.

Before I link you to the relevant tutorial, have you considered using DigitalOcean's DNS service, located in your Cloud admin panel under "Networking > Domains"?

If not, I would recommend trying this first as it will be simpler, faster and more reliable than running your own DNS server.

Here are some relevant links to hosting your domains on DigitalOcean's DNS:

Overview: https://www.digitalocean.com/docs/networking/dns/
Quickstart: https://www.digitalocean.com/docs/networking/dns/quickstart/

It's a two step process, add your domain then add your records (eg, "www"):

https://www.digitalocean.com/docs/networking/dns/how-to/add-domains/
https://www.digitalocean.com/docs/networking/dns/how-to/manage-records/

If that doesn't meet your requirements, here is a tutorial on setting up BIND for DNS - keep in mind that it expects two servers in this setup, a primary and a secondary, in case the primary goes down:

https://www.digitalocean.com/community/tutorials/how-to-configure-bind-as-an-authoritative-only-dns-server-on-ubuntu-14-04

The tutorial is a little older, so be on the lookout for differences with your current operating system. The BIND info should still be valid.

Hope this helps and good luck!

by Justin Ellingwood
Bind, the most popular DNS server, is used as the backbone of much of the world's DNS system. In this guide, we will discuss how to configure a pair of DNS servers to act as primary and secondary authoritative-only DNS servers for your domains. We will be demonstrating this on Ubuntu 14.04.
  • Hello,

    First of all, thank you for answering my question, I often lead training sessions during which I teach students system administration with linux (debian 9). So it's as part of the practical work, I don't intend to implement it in a production environment. I would like to do this manipulation with a single bind server (the primary one), make example1.com and example2.com coexist on the same bind server.

    Thank you

Ah, that would be one of the few good reasons to run your own BIND server these days. I linked to the BIND tutorial and any BIND instance will support multiple domains / zones. If you follow all of the instructions in that tutorial except for the secondary stuff, you should have a working system.

If you are actually delegating these example domains at the registrar (as reflected in WHOIS), they may require 2 IP addresses for your name servers (plural) - you can request and use what is called a "Floating IP" with your Droplet, effectively giving you a second IP address to use for your one BIND instance.

More info on those here: https://www.digitalocean.com/docs/networking/floating-ips/

Let us know how you make out with the BIND tutorial and if there are any specific parts that you need assistance with, please ask :)

Have another answer? Share your knowledge.