473,513 Members | 2,795 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DNS.GetHostEntry()

Hi all,

I have a small "irritant" to do with DNS resolving in .NET Framework v2.0.

For this example, assume the following network information;
Local IP address is 192.168.0.10, on a PC named "PC_01"
Remote address is 192.168.0.20, on a local LAN, and named "PC_02"

DNS.GetHostByAddress("192.168.0.20").Hostname returns "PC_02"
DNS.Resolve("192.168.0.20").Hostname returns "PC_02"

Both these methods are marked obsolete in v2.0 of the framework, and
GetHostEntry is recommended as the replacement. However;

DNS.GetHostEntry("192.168.0.20").Hostname returns "192.168.0.20" .....
not the hostname!!

The only other thing I've noticed is that
DNS.GetHostEntry("192.168.0.10").Hostname returns "PC_01", so it seems to
work on the local node.

Anyone got any idea why!??! Or is it just an annoying bug in
GetHostEntry()?? :(
__________________________________
The Grim Reaper
Feb 6 '06 #1
2 5370
Try getting the Host entry using the host name... Dns.GetHostEntry
("PC_02"); and see if it returns the right IPAddress. If the IPAddress
returned is different then your DNS server is not mapping 192.168.0.20
as PC_02, or if an exception occurs then the DNS server cannot resolve
the address...

This is not a bug but a behaviour of how DNS lookups are done. IP
address that do not have related DNS records will be returned with the
host name as the ip address provided in the lookup.

Hope this helps...
- NuTcAsE

Feb 7 '06 #2
I'm afraid that doesn't help! DNS.GetHostEntry("PC_02") definitely returns
the correct IP (and yes, each PC has only one NIC and one IP).
There are no exceptions.
I don't actually know that much about DNS server activity in XP Pro
(although I should! :S)...
Pinging PC_02 returns the text "Pinging PC_02 [192.168.0.20] ...." etc.
I'm pretty sure the network/DNS config is fine.. because as I originally
mentioned, GetHostByAddress() works fine - it's just marked as obsolete in
Framework v2.0.

"NuTcAsE" <ra********@gmail.com> wrote in message
news:11*********************@z14g2000cwz.googlegro ups.com...
Try getting the Host entry using the host name... Dns.GetHostEntry
("PC_02"); and see if it returns the right IPAddress. If the IPAddress
returned is different then your DNS server is not mapping 192.168.0.20
as PC_02, or if an exception occurs then the DNS server cannot resolve
the address...

This is not a bug but a behaviour of how DNS lookups are done. IP
address that do not have related DNS records will be returned with the
host name as the ip address provided in the lookup.

Hope this helps...
- NuTcAsE

Feb 7 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
6959
by: ad | last post by:
Hi, I use the code below to get the IP of computer: My computer has only one ip: 192.168.0.100, But there are tree IPs get by GetHostEntry: 192.168.0.100 192.168.0.1 192.168.122.1 Why?
1
2521
by: Scott J. Peterson, MCSD, MCPSB, MCT | last post by:
I'm trying to emulate passing the 'SERVER' parameter in an NSLOOKUP using the Dns namespace, but I don't see anywhere this can be set. For example, I may do this; IPHostEntry ipEntry = Dns.GetHostEntry(strServerIP); ....but I want to specify WHICH DNS server to resolve against, not just the default. From a command prompt I would do...
4
15086
by: css | last post by:
When I call Directory.Exists for a UNC path like below... if (Directory.Exists(@\\SomeServer\C) == false) { .... } and that server does not exist on the connected network, it takes around a minute to return from the call which properly returns false.
3
7437
by: RWF | last post by:
I am trying to do a reverse DNS lookup using Dns.GetHostEntry in .NET 2.0, but it seems to kind of crap out when the result is an answer with multiple records. It doesnt seem to give any type of answer. The old Dns.GetHostByAddress seems to work partially by atleast returning 1 IpHostEntry, but it has been deprecated. Any ideas on how...
2
6183
by: The Grim Reaper | last post by:
Hi all, I have a small "irritant" to do with DNS resolving in .NET Framework v2.0. For this example, assume the following network information; Local IP address is 192.168.0.10, on a PC named "PC_01" Remote address is 192.168.0.20, on a local LAN, and named "PC_02" DNS.GetHostByAddress("192.168.0.20").Hostname returns "PC_02"...
7
2139
by: kvnsdr | last post by:
I can type an IP address and receive Internet domain name and my workstation name however no other IPs of computers on our internal network will resolve to a thier machine name only to the same IP that is entered. What's up Microsoft???? I can say that before we switched over .NET 1.1 to 2.0 the Dns.Resolve(entry); would find a name for any...
3
16572
by: Steve Richter | last post by:
I am using Dns.GetHostByAddress and Dns.Resolve to successfully resolve and IP address to an IPEndPoint. IPEndPoint ep = null; IPAddress ipAddr = IPAddress.Parse(m_sRemoteHost); ep = new IPEndPoint(Dns.GetHostByAddress(ipAddr).AddressList, m_iRemotePort); // ep = new IPEndPoint(Dns.GetHostEntry(ipAddr).AddressList, m_iRemotePort); // ep...
5
14477
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
I am trying to get the DNS name of an arbitrary IP address on the network. If I use GetHostEntry as the documentation suggests I only get the name of the machine I am running the code on. All other IP’s returns the IP in the HostName property of the IPHostEntry object returned by GetHostEntry. If I use Dns.GetHostByAddress or...
3
15551
by: desire83 | last post by:
hello, im new in c#.net... i have made a server application and a client application for the same machine...the server is suppos to send a string to client when the button on the server application is pressed...but im not recieving the string on my client application here are the codes for both the applications SERVER: using System; using...
0
7273
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7181
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7399
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7570
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
5105
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3256
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
1615
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
821
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
480
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.