'DNS for virtual machines on Windows working computer?

The company uses Windows computers for work, and we need to simulate a testing environment with virtual machines. We are currently using VirtualBox but can switch to other platforms, e.g. VMware, Hyper-V, Docker, etc.

When having many virtual machines, we need to manage them by hostnames because using the IP addresses is too error-prone.

So, we list the hostnames and IP addresses in a master copy of the hosts file shared between the local physical host and the virtual machines to simulate the effect of a DNS.

However, certain applications have designs to bypass the hosts file for performance or reliability considerations.

For example, the Microsoft SSIS (SQL Server Integration Service) correctly resolves domain names through the real DNS but does not recognize the names in the hosts file. Therefore, we cannot fetch data from a testing database on a virtual machine.

Another example, the MariaDB clustering facility Galera does not recognize the hosts file either, and we had to use raw IP addresses to configure the virtual machine cluster.

I wonder if there is a way to have a real DNS for the virtual machines on the local computer. I appreciate your help and hints.



Solution 1:[1]

Assuming all IP addresses are (and will forever remain) static (i.e. no DHCP):

Like @Hani said:

1. Set up a DNS Server, and add all your records to it.

2. Point all machines to that DNS Server.

  • In Windows:

  • In Linux:

    • Probably edit /etc/resolv.conf
    • Or refer to your specific distro's docs. (or something like netplan docs)

If IP addresses are assigned via DHCP, Step 2 is replaced with:

Configure the DHCP Server to hand out your DNS Server Adress in its leases, and make sure it always assigns the same ip addresses to the same machines. (static leases)

^ These links are for openwrt routers, but it's basically always the same process.

Solution 2:[2]

create additional virtual machine on the same/other physical machine. configure this VM as a DNS server, then on each other VM point to the DNS server as their primary DNS.

is this what you are trying to achieve?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Yarin_007
Solution 2 Hani