Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

For example:

Server: server1.contoso.com
IPs present on server: Initially configured statically with 10.10.20.100, it had two additional IPs added to the same NIC, 10.10.20.20 and 10.10.20.102.
A Record for server1.contoso.com points at 10.10.20.100

When pinging server1.contoso.com from another machine returns the proper IP of 10.10.20.100. Tracert shows going through the proper channels.

When pinging server1.contoso.com when on server1.contoso.com returns 10.10.20.20. Tracert shows it not going to DNS and resolves on the server to the lowest numerical IP.

Is there any solution for this occuring? I'm trying to write a script that will run on the server and return the IP that was configured as the static IP on the NIC properties.

Using a WMI class, I am able to see all the IPs on that NIC, so until now I have been assuming the first item in the array was what was configured, but ideally would rather just reach out to DNS to get the IP.

Any suggestions?

share|improve this question
add comment

1 Answer

It sounds like you have two conflicted expectations here. On the one hand, you seem to expect it to make a DNS query. On the other hand, you want to show the "P that was configured as the static IP on the NIC properties". It is possible to get conflicting information from those two items.

Lacking more information, I'll just point you on using the DNS record. The way to do that is to explicitly ask the DNS server:

PS> [System.Net.Dns]::GetHostAddresses("server1.contoso.com")

And if you don't know the fully-qualified hostname at the time of building the script, use this in place of the server name:

"$env:computername.$env:userdnsdomain"
share|improve this answer
    
To explain myself a bit more, the static IP configured on the NIC properties IS the IP that is configured as the A record for the hostname. When I use command you suggested, it returns an array of objects which contain the 3 IPs configured on the server, in this order (10.10.20.20, 10.10.20.102, 10.10.20.100). It isn't reaching out to DNS to get the response. –  Jared Jan 22 '13 at 19:54
    
I ended up just writing a small Powershell script that will query and parse nslookup to make the output usable elsewhere in my script. –  Jared Jan 24 '13 at 16:49
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.