Link to home
Start Free TrialLog in
Avatar of Robert Harris
Robert Harris

asked on

Verify IP Address and Host Name (VB.NET)

Hi.  There are times when DNS and a PC name do not match, and can determine this with PING -a, for example, I ping Computer 1 and returns an IP address, then PING -a the IP address and find the IP is associated with Computer2. I once wrote a simple batch that pinged the PC by name, captured the IP, then PING -a and if the PC names don't match, there's a conflict. That worked well.

Is there an elegant way to do this type of verification in VB.net?   I have an app that depends on connectivity to a remote PC host (on an AD domain), but it fails if there's a DNS conflict.  I'd like to verify there's an actual DNS issue in VB, instead of calling on CMD to check.
Avatar of David Favor
David Favor
Flag of United States of America image

Better to do an actual DNS lookup, rather than use ping.

Or if VB has no native lookup capability, run nslookup or dig for DNS lookups.

Keep in mind, if DNS ever returns incorrect results, there's likely no way to take any recovery action in your code.

This is a DNS problem which should be fixed, else your code will always work oddly... when trying to take action using the bad IP... or just trying to die when wrong IP comes in. Far better to fix the related DNS entries.
ASKER CERTIFIED SOLUTION
Avatar of Chinmay Patel
Chinmay Patel
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Robert Harris
Robert Harris

ASKER

Thank you both for your responses! I will look into the DNS class...