Getting my VMware server to resolve DNS in a reasonable time.
I have a Windows 2012 server that I run under VMWare. I've probably mentioned this image before, as it's the one I use for my Tridion research. I'm fairly unusual in that I like to have my database server running "on the bare metal" of my laptop rather than in the Windows Server image. It's probably just perversity or masochism or whatever, but that's how I roll. What this means is that I have two network interfaces on the image: one configured as "Host only", which I use for my database connections and other "on the box" stuff, and another running NAT. Sure, you could run a development image completely isolated from the Internet, but it'd be a pain, so I run the NAT interface as well.
All good in theory, but as it turned out, it was a pain anyway, because it was taking 10 seconds to resolve a DNS name. Don't ask me why 10 seconds - presumably it was hitting some timeout and then trying an approach that worked better. Anyway - it was getting annoying. Sure I could flip out of the image to run a browser outside, but nah! Apart from anything else, I hate to be irritated by things I don't understand. I don't mind having things I don't understand, - gee, you'd go crazy! - but if it's an in-your-face irritation, that's another story.
So I poked around a bit. I could run:
in my powershell on the image and it would take 10 seconds. Natively on the laptop - instant response. So I had a quick look in the VMWare network settings. There are some obscure settings on the NAT interface for policies for automatically detecting DNS servers. But hang on - was it attempting to get DNS from the Host only interface, or the NAT one? So what would nslookup tell me:
PS C:\Users\Administrator> nslookup Default Server: UnKnown Address: 192.168.126.1 > www.yahoo.com Server: [192.168.126.1] Address: 192.168.126.1 DNS request timed out. timeout was 2 seconds. DNS request timed out. timeout was 2 seconds. DNS request timed out. timeout was 2 seconds. DNS request timed out. timeout was 2 seconds. *** Request to [192.168.126.1] timed-out > server 192.168.146.2 Default Server: [192.168.146.2] Address: 192.168.146.2 > www.yahoo.com Server: UnKnown Address: 192.168.146.2 Non-authoritative answer: Name: ds-eu-fp3.wa1.b.yahoo.com Addresses: 2a00:1288:f00e:1fe::3000 2a00:1288:f006:1fe::3000 2a00:1288:f006:1fe::3001 2a00:1288:f00e:1fe::3001 18.104.22.168 22.214.171.124 Aliases: www.yahoo.com fd-fp3.wg1.b.yahoo.com ds-fp3.wg1.b.yahoo.com ds-eu-fp3-lfb.wa1.b.yahoo.com
OK - so the first thing that this told me was that the default lookup was on my Host only interface, and that this was failing. When I manually set the server to the one on the NAT interface, boom... the response came back in a split second.
Next problem - how do I get it to default to the one that works (yes - I could also attempt to get the Host only one working properly, but not if it's easy to switch to the other - llfe's too short, and with networking, getting it to stop being irritating is much more achievable than understanding!).
After a bit of Googling I discovered that you Windows brings up the network interfaces in a specified order, and the first one becomes the "primary" interface, which in turn is used as the default for DNS and goodness knows what else. All I needed to do was change the order. I picked up a hint from The Regime and was almost surprised to find that also in Windows Server 2012, you can get to the advanced settings of the network interfaces by hitting and releasing the Alt key. (Who knows about this stuff? Isn't that just disturbing?) A couple of minutes later I was testing it and finding that it worked.
So it's all good. I still don't understand networking, but that's never been a serious itch for me.