Score:0

Get all hostnames in local DNS for current Windows server

ec flag

I've deployed BGInfo from SysInternals to all of our servers, both physical and virtual. However, a few of our servers have multiple hostnames to support "backward compatibility" with some of our legacy software systems after a server was replaced or its functions were merged with another server. In some cases, this may include several "alternate" hostnames that go back several years.

EXAMPLE:

Alternate Hostname (original computer): NT-PROD
Alternate Hostname (files/services merged from a retired server): NT-DATA
Alternate Hostname (hardware failure = new computer): PRODUCTION-07
Current Computer Name (physical server migrated to virtual): PRODUCTION-21

Using the basic WMIC to get the computer name just returns the current name specified in the System Properties, while doing an NSLOOKUP on the server's IP address apparently does the same thing. Is there a way I can actively retrieve all the DNS hostnames to which this specific server will respond for inclusion in my BGInfo wallpaper?

I suppose I could create a text file (or something) that BGInfo could check for alternate hostnames, but I'm trying to make this as "idiot-proof" as possible so I don't forget to update/apply any future DNS changes, or accidentally overwrite something with incorrect information. I readily admit that I'm not "fluent" in PowerShell scripts or more complex WMIC queries, but I would guess that's where we're headed.

in flag
One machine only has "one name". What you have here is multiple DNS names resolving to the same machine, correct? You need to list the DNS, and group all names resolving to the same IP/machine.
my flag
One more clarification - you have multiple DNS names resolving to the same IP. Correct?
G_Hosa_Phat avatar
ec flag
@NiKiZe - And that's pretty much exactly what I'm trying to figure out how to accomplish in a way that can be incorporated into - or, at least, accessed by - the BGInfo utility. I apologize if the question is unclear in that regard.
G_Hosa_Phat avatar
ec flag
@uSlackr - Well, I'm going to say yes. Each of these systems have multiple NIC's, so there are additional IP's that can "get there". However, for example, if I `PING`, say `NT-PROD`, it gives me an IP address. Then I do an `NSLOOKUP` on that IP address, and it returns, say, `PRODUCTION-21`. Does that make sense? (*is it clear I'm somewhat out of my depth here? I mean, I know the* basics/fundamentals *of DNS, but this is a tangled mess that catches me up sometimes*)
Score:0
my flag

Try Resolve-DNSName <IP> It should return all the names register to the server IP

Keep in mind this will only work with your local zones. Not internet wide or any madness like that (See answers to https://stackoverflow.com/questions/31539904/get-all-dns-records-associated-with-an-ip for more on that)

G_Hosa_Phat avatar
ec flag
Just to be sure, PowerShell, right? I have an idea of how to get there from here, but it's gonna take some twisty logic...
my flag
Of course. What's the twisty part? Plugin the server's IP... Keep in mind - the server doesn't need to know about these other names. It will only care about its computer name (and maybe a name in an IIS config if it is different)
G_Hosa_Phat avatar
ec flag
The "twisty" part is actually based on your point of clarification in the OP comments as well as my own basic testing thus far. The machine has multiple NIC's (and multiple IP's). In my testing, I `PING NT-PROD`, I get `192.168.1.6`. `NSLOOKUP` on that IP returns `PRODUCTION-21`. `Resolve-DNSName` with that IP returns `PRODUCTION-21`. When I PING `PRODUCTION-21`, I get `172.16.25.50`. `NSLOOKUP` on *that* IP gets nothing, and neither does `Resolve-DNSName`. The only time I get `NT-PROD` here is when I type it myself, so either I'm missing something, or I'm gonna need some bigger code. :P (1/2)
G_Hosa_Phat avatar
ec flag
(2/2) Like I said, I've got some ideas, but they involve enumerating through all of the computer's NIC's and IP's, then reading through the DNS zone to match up each of those IP's with any names it finds. At that point, it can write it all out to a file somewhere and I should be able to read it into BGInfo from there. Just *way* more complicated than I had originally anticipated. Not surprising, but I may have to put that particular project off a little while.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.