473,785 Members | 2,349 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.GetHostByNa me doesn't
return the host name's aliases in the IPHostEntry.Ali ases
list. But if I pass a host alias to GetHostByName it
returns the alias in IPHostEntry.Ali ases and the true host
name in IPHostEntry.Hos tname.

It appears that the IPHostEntry.Ali ases 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 4786
"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.GetHostByNa me doesn't
return the host name's aliases in the IPHostEntry.Ali ases
list. But if I pass a host alias to GetHostByName it
returns the alias in IPHostEntry.Ali ases and the true host
name in IPHostEntry.Hos tname.

It appears that the IPHostEntry.Ali ases 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.Ali ases 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.Ali ases 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
2072
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 looked like about 20:20 split on the following syntaxes: 1 def func(arg1, arg2, arg3) : function... 2 def func(arg1, arg2, arg3): function...
5
2403
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 relevant announcements. If you're interested, drop me a note. But if for some reason you think that this discussion is fine here at the c.l.py, please let me know. ** LONG POST AHEAD **
10
2663
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 | don't, I need to know. Flames welcome.
8
4376
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 somebody explain it to me? I am using MSVC 6.0. Thanks a lot,
11
6601
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 where the job is running, the job runs sucessfully, PDF files got generated, everything is good. If I scheduled the job to run at the time that I am not logged into the server, Access is not able to print to the printer. The error is pretty...
3
2005
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 application. If you have not used the keyword 'Overridable' then read on for sure... If you setup a child class and you want to override a method in your base class, you may see the squiggles under your child's method name. The pop-up/build error says...
8
2415
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 into the bin directory but am not able to progress. Can anyone please guide me to an online tutorial on the subject. Thanks,
1
831
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 of time for any help or feedback. Cheers, Peter
6
2944
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 calling Mesh class functions. Let's say they point to each other like this: class Vertex { HalfEdge *edge; }; class HalfEdge { Vertex* vert;
8
8948
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 throws up the following error in the browser: CS1061: 'System.Web.UI.WebControls.TextBox' does not contain a definition for 'Web' and no extension method 'Web' accepting a first argument of type 'System.Web.UI.WebControls.TextBox' could be found...
0
9646
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10157
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9956
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8982
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6742
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5386
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5514
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4055
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
2
3658
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.