I've created 2 virtual servers. Let's call them "website1.com" and "website2.com".
I've added "prepend domain-name-servers 127.0.0.1" to "dhclient.conf". This correctly inserts 127.0.0.1 as the "primary DNS" before the DHCP-provided DNS from my ISP, so it should look up domain names with the DNS server on localhost first, right?
In Virtualmin, I've ensured that the virtual servers have been given DNS entries.
Now, the tricky bit is that this is a development machine, so I'm behind a NAT. I've tried both "127.0.0.1" and "192.168.0.x" - the machine's NAT address - as the shared IP address. When I re-check the configuration, everything's fine except that it says that "192.168.0.x" does not actually equate to my externally visible IP address (which is true enough, as I'm behind a NAT here).
When I enter "website1.com" or "website2.com" into a browser, the websites are not appearing but it's going to the wider Internet to look up those domain names.
(I did "hack" things by adding "127.0.0.1 website1.com" to my "/etc/hosts" file, but this is no real solution because if I type "website2.com" then it changes to "website1.com" and website 1 appears. That is, "website2.com" is on 127.0.0.1 as well, and because of the "hosts" entry, that's equated to "website1.com" and that's what shows up as the default website for 127.0.0.1.)
Basically, before this, I've never touched DNS before, so I am rather clueless about how to configure this properly.
What I want is that when I type "website1.com" or "website2.com" into the browser address bar, then it'll go to my localhost DNS server and correctly pull up the right website. And for this to work whilst being behind a NAT as well, for this development machine.
But, yes, feel free to expand on this, if you want, to explain how it'll differ for the real server that this will all eventually go on (where I will have a proper static IP address and properly registered domain names and not use DHCP and so forth, but just for development and learning purposes, this is all happening behind a NAT for the time being until it's finally ready for the prime time of the wider Internet).
By the way, how exactly does Virtualmin know the difference between websites? What I mean is that, as they're on a shared IP address (127.0.0.1), when the domain names are converted to IP addresses, aren't both "website1.com" and "website2.com" converted to "127.0.0.1", so how are the virtual servers differentiated anyway?