Primary and secondary DNS on the same machine

Good morning everyone, I wonder if it’s possible to run a primary and secondary dns server on the same machine. I have two ip’s available and everything is running through XenServer or do not have many reasons to separate dns servers since the machine is the same. previously worked with CPanel and he offered me this option in the installation and I’m about 2 weeks with Virtualmin on a VPS however I could not even configure it to work well.

Thank you in advance for all and take this opportunity to congratulate them for optimal system.


I wonder if it’s possible to run a primary and secondary dns server on the same machine.

Yup! A lot of folks do that.

There’s nothing special you need to do actually – just setup both IP addresses on your one server, and assign and to your two IP addresses. It should just work!

You wouldn’t actually be using a primary and secondary on the same machine – you’d essentially just be using a primary with two IP addresses.

After you setup your second IP address, you may just need to restart BIND in order to make sure it’s listening on both IP’s.


OK, but the ns2 have to hand in creating it? I found where I set the ip address should be assigned to ns1 and yy.yyy ip address should be assigned to ns2. Can you give me a light. Thank you!

Please note though that by doing that, you defeat the purpose of having a primary and secondary NS in the first place: Redundancy in case of server failure.

Yes I understand, the point is that everything is running on a server with XenServer and have four virtual machines on this server. But I think the ideal solution then it will be posted by our friend formerly andreychek. I expressed myself poorly actually want two zones with different ip’s to get register the domains that will be allocated to these servers. But from what I saw, each virtual server created will have to manually create the NS2 this server, because I could not know where this setting that, for the virtualmin do it automatically. Thank you!

Well, I’m not entire certain I understand what you’re asking there…

But I’ll toss out some things that can assist in getting DNS setup.

First, there’s some documentation on setting up nameservers here in the section named “How do I setup nameservers for my server”:

Also, if you wanted a slave DNS server on a separate server, you could use this (though this is a more complex setup):

Do either of those by chance answer your question?


The first steps I always do when setting up a new box is to bind the IP to the box. Normally only the first IP is bound when setting up a box.

Webmin- networking- network configuration- network interfaces- eth0 -Add vrtual interface- Fill in the IP and hit Create. (I would do these steps under the “Active Now and Activated on Boot” tabs just in case.
Then hit “Return to network interfaces” Do not hit Save in the “Edit Bootup Interface” section or you will loose connection…

Then go to Host Addresses- Add a new host address -fill in the 2nd IP and ns2.domain.tld , ns2
Now the box knows about the IP and how its called so it can be used in automatic zone setup by virtualmin.

Also dont worry about redundancy too much as you only have one box. If that box goes down it doesn’t matter how many DNS servers you have. More importantly some ccTLD’s or ISP’s demand different IP ranges for the dns zones. If that is the case for you then I would definitly set up a slave dns server in a different location.

“different IP ranges”: Yep, that’s e.g. the case for .de, which requires different /24 networks for nameservers.

About redundancy: Yes, if you indeed only have one hosting machine for all of it, it doesn’t really matter if a secondary nameserver might still be up if the hosted stuff is down.

There are situations though where a secondary NS helps. E.g. if a customer uses your hosting for web pages, but uses an external service for email. In that case, the nameserver should be redundant and be able to deliver MX records even if your main hosting box is down. Email continues to work then.