473,387 Members | 1,485 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Using Dns class

I'm using the Dns class to query host names to check that
they actually exist on our network and to determine the
aliases for each host name. However, I've noticed that the
IPHostEntry instance returned by Dns.GetHostByName doesn't
return the host name's aliases in the IPHostEntry.Aliases
list. But if I pass a host alias to GetHostByName it
returns the alias in IPHostEntry.Aliases and the true host
name in IPHostEntry.Hostname.

It appears that the IPHostEntry.Aliases does not work in
the way suggested by the SDK docs, but can anyone tell me
how I can get a list of DNS aliases for a known DNS host
entry?

Thanks

John
Jul 21 '05 #1
2 4761
"Johno" <jo***@hotmail.com> wrote in message news:<02****************************@phx.gbl>...
I'm using the Dns class to query host names to check that
they actually exist on our network and to determine the
aliases for each host name. However, I've noticed that the
IPHostEntry instance returned by Dns.GetHostByName doesn't
return the host name's aliases in the IPHostEntry.Aliases
list. But if I pass a host alias to GetHostByName it
returns the alias in IPHostEntry.Aliases and the true host
name in IPHostEntry.Hostname.

It appears that the IPHostEntry.Aliases does not work in
the way suggested by the SDK docs, but can anyone tell me
how I can get a list of DNS aliases for a known DNS host
entry?

John -

This is not a bug in GetHostByName() or IPHostEntry - it is the
way DNS works. You should notice that using the nslookup command
produces the same results. It is impossible to list all of the alias
records that might be associated with a host name record without
querying the entire DNS tree (its possible for an alias record to
point to a host in another domain). The GetHostByName() method will
walk the chain of aliases to the root host name if it is supplied an
alias name. That is what the IPHostEntry.Aliases property is used for.

As an example, try www.microsoft.com. If you look it up, it shows
that it is an alias, pointing to www.microsoft.com.edgesuite.net,
which is another alias pointing to the host a562.cd.akamai.net. Now if
you look up www.microsoft.com.edgesuite.net, it only shows that it is
an alias to the a562.cd.akamai.net host - it doesn't know about the
www.microsoft.com alias, as it is farther up the alias chain. The
nslookup can only follow the alias chain down to the actual host name.

Some DNS utilities (such as the Unix 'dig' command), can query an
entire domain looking for all of the alias (CNAME) and host name (A)
DNS records. You may have to model your app after one of those
programs to get the information you are interested in. Hope this helps
shed some light on your problem. Good luck with your network app.

Rich Blum - Author
"C# Network Programming" (Sybex)
http://www.sybex.com/sybexbooks.nsf/Booklist/4176
"Network Performance Open Source Toolkit" (Wiley)
http://www.wiley.com/WileyCDA/WileyT...471433012.html
Jul 21 '05 #2
Rich,

Thanks for the reply. I did suspect that this was the way
DNS works because, like you say, NSLOOKUP behaves in the
same way as GetHostByName()/IPHostEntry.

Regards

John
John -

This is not a bug in GetHostByName() or IPHostEntry - it is theway DNS works. You should notice that using the nslookup commandproduces the same results. It is impossible to list all of the aliasrecords that might be associated with a host name record withoutquerying the entire DNS tree (its possible for an alias record topoint to a host in another domain). The GetHostByName() method willwalk the chain of aliases to the root host name if it is supplied analias name. That is what the IPHostEntry.Aliases property is used for.
As an example, try www.microsoft.com. If you look it up, it showsthat it is an alias, pointing to www.microsoft.com.edgesuite.net,which is another alias pointing to the host a562.cd.akamai.net. Now ifyou look up www.microsoft.com.edgesuite.net, it only shows that it isan alias to the a562.cd.akamai.net host - it doesn't know about thewww.microsoft.com alias, as it is farther up the alias chain. Thenslookup can only follow the alias chain down to the actual host name.
Some DNS utilities (such as the Unix 'dig' command), can query anentire domain looking for all of the alias (CNAME) and host name (A)DNS records. You may have to model your app after one of thoseprograms to get the information you are interested in. Hope this helpsshed some light on your problem. Good luck with your network app.
Rich Blum - Author
"C# Network Programming" (Sybex)
http://www.sybex.com/sybexbooks.nsf/Booklist/4176
"Network Performance Open Source Toolkit" (Wiley)
http://www.wiley.com/WileyCDA/WileyTitle/productCd- 0471433012.html.

Jul 21 '05 #3

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

Similar topics

4
by: Michael Sparks | last post by:
Anyway... At Europython Guido discussed with everyone the outstanding issue with decorators and there was a clear majority in favour of having them, which was good. From where I was sitting it...
5
by: Carlos Ribeiro | last post by:
Hello all, I'm posting this to the list with the intention to form a group of people interested in this type of solution. I'm not going to spam the list with it, unless for occasional and...
10
by: Christopher Benson-Manica | last post by:
Why can't I use a class destructor in a using declaration: using MyClass::~MyClass; ? -- Christopher Benson-Manica | I *should* know what I'm talking about - if I ataru(at)cyberspace.org ...
8
by: Douglas | last post by:
**** Post for FREE via your newsreader at post.usenet.com **** Hello, The following code does not compile if line 3 is uncommented "using namespace std". I do not understand it. Could...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
3
by: flat_ross | last post by:
For anyone who is just getting into VB.NET and/or is starting to work with inheritance I would like to point out a potential pitfall. We found this confusion recently when code-reviewing an...
8
by: acb | last post by:
Hi, I wrote a DLL Component (using Visual Studio 2005) and managed to include it into a C# Console application. I am now trying to include this component into a Web project. I copy the DLL...
1
by: Peter Nofelt | last post by:
Hey All, I am having issue with serializing a class and its base class using ..net 2.0. I am using IXmlSerializable I've provided code displaying my at the bottom of this post. Thanks ahead...
6
by: ivan.leben | last post by:
I want to write a Mesh class using half-edges. This class uses three other classes: Vertex, HalfEdge and Face. These classes should be linked properly in the process of building up the mesh by...
8
by: =?Utf-8?B?Q2hyaXMgSGFsY3Jvdw==?= | last post by:
Hi there I've successfully added some .NET validation controls to a page (using <asp:RequiredFieldValidator ...), however when I try to set the 'display' property to 'dynamic', my page then...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...

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.