[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1797
  • Last Modified:

How to resolve an IP Address to a host name

I'm using Delphi XE2 Upd4HF. My PC is running Windows 2008 R2. I'm in an Active Directory domain that has DNS integrated into it.

My PC has a single NIC with two IP Addresses assigned to it. Under the DNS properties of the NIC I have the 'Register the connection's addresses in DNS' checked. My PC is not a domain controller or a DNS server.

Hostname: dakota
Domain: nsw.com
1st IP Address: 192.168.10.40
2nd IP Address: 192.168.10.41

When I look at the DNS Forward entries I have two for this host:
dakota        Host(A)      192.168.10.40       9/21/2012 8:00:00 PM
dakota        Host(A)      192.168.10.41       9/21/2012 8:00:00 PM

I add a new Host(A) record for 'dakota2' using Address: 192.168.10.41' and create a PTR record.

So now I have another DNS Forward entry:
dakota2       Host(A)      192.168.10.41       Static

When I run an nslookup from the command line using the IP addresses I get the correct FQN.
nslookup 192.168.10.40 returns dakota.nsw.com
nslookup 192.168.10.41 returns dakota2.nsw.com

However I have not been able to code this using Delphi to get the same results. I've use ICS, IP*Works, and getnamebyaddr. All of them return dakota.nsw.com for both IP Addresses.

I've even tried deleting
dakota        Host(A)      192.168.10.41       9/21/2012 8:00:00 PM
from DNS.

What do I need to do to get the same results that nslookup returns?

Thanks
0
softbreeze
Asked:
softbreeze
  • 4
  • 2
1 Solution
 
arnoldCommented:
Not familiar with Delphi.
When there are two records, getnamebyaddr returns a structure of multiple records. You need to chek the next record.

Run nslookup -debug IP to see what transactions are performed and what responses are received.
0
 
softbreezeAuthor Commented:
Thank you. However I looked thru the MSDN info for the GetHostByAddr and I don't see that it returns multiple structures, one for each record. I do see that I can get all the IP addresses for host, but my issue is trying to resolve the IP to the correct hostname as described in my initial question.
0
 
arnoldCommented:
The reverse is an accounting entry to reference back for forward/reverse matching.

Presumably you looked at http://msdn.microsoft.com/en-us/library/windows/desktop/ms738521(v=vs.85).aspx
The example remotehost is being defined as a pointer.

I believe gethostbyaddr should rerun a reference to a linked items of all hostnames to which the ip resolves.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
softbreezeAuthor Commented:
Yes I have read many msdn articles including the one you have referenced. I'm still trying to sort this out. Anyone else have an idea why I am seeing this behavior?
0
 
softbreezeAuthor Commented:
I figured this out. However I'm giving arnold the points for at least responding.
Here is what I found out. On my network adapter settings, under the DNS tab, the 'Register this connector's addresses in DNS' was checked. This is what caused the forward name duplicates with different IP addresses. Reverse DNS was fine. I unchecked it, deleted the incorrect entries in DNS along with the PTR records. Rebooted and verified that I had one forward entry and one PTR entry. Then I manually added the second IP in DNS and have had no more issues.

So for now I'm done with this.
0
 
softbreezeAuthor Commented:
You get the points for responding.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now