473,625 Members | 3,253 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DNS Nameserver Lookup

I am using the System.Net namespace to do DNS lookups of a host and return
their IP address. However I haven't figured out how to use the namespace to
take a domain name and find the responsible nameservers. Does anyone have an
idea how to do this?
Jun 12 '07 #1
1 2262
Magnus R,

You have a couple options.

You could use PInvoke for the following signature:
Private Declare Function NetGetDCName Lib "netapi32.d ll" (ByVal
strServerName As Object, ByVal strDomainName As Object, ByVal pBuffer As
Long) As Long
You could use the System.Net namespace:

Dim MYIP As System.Net.IPHo stEntry =
System.Net.Dns. GetHostEntry(My .Computer.Name)
Dim IPaddress As String = MYIP.AddressLis t.GetValue(0).T oString
Console.WriteLi ne(System.Net.D ns.GetHostEntry (IPaddress).Hos tName)
You could also use the System.Net.Netw orkInformation namespace for the long
way around, but more detail. Check out this code:

Imports System.Net
Imports System.Net.Netw orkInformation

Public Class NetworkInfo
Public Shared Sub ShowIPAddresses ()
Dim computerPropert ies As IPGlobalPropert ies =
IPGlobalPropert ies.GetIPGlobal Properties()
Dim nics() As NetworkInterfac e =
NetworkInterfac e.GetAllNetwork Interfaces()
Console.WriteLi ne("Interface information for {0}.{1} ", _
computerPropert ies.HostName, computerPropert ies.DomainName)
If (nics Is Nothing OrElse nics.Length < 1) Then
Console.WriteLi ne(" No network interfaces found.")
Return
End If

Console.WriteLi ne(" Number of interfaces ............... ..... :
{0}", nics.Length)
For Each adapter As NetworkInterfac e In nics
Dim adapterProperti es As IPInterfaceProp erties =
adapter.GetIPPr operties()
Dim dnsServers As IPAddressCollec tion =
adapterProperti es.DnsAddresses

If (Not dnsServers Is Nothing) Then
For Each dns As IPAddress In dnsServers
Console.WriteLi ne(" DNS Servers
............... ............... : {0}", dns.ToString())
Console.WriteLi ne(" Server Name
............... ............ : {0}",
System.Net.Dns. GetHostEntry(dn s.ToString).Hos tName)
Next
End If
Next
End Sub
End Class
You could also use the registry:
http://www.java2s.com/Code/CSharp/Ne...DNSServers.htm

Hope this helps,
Steve
"Magnus R" <ro******@hotma il.comwrote in message
news:e5******** ******@TK2MSFTN GP04.phx.gbl...
>I am using the System.Net namespace to do DNS lookups of a host and return
their IP address. However I haven't figured out how to use the namespace to
take a domain name and find the responsible nameservers. Does anyone have
an idea how to do this?

Jun 13 '07 #2

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

Similar topics

8
2029
by: Lucas Lemmens | last post by:
Dear pythonians, I've been reading/thinking about the famous function call speedup trick where you use a function in the local context to represent a "remoter" function to speed up the 'function lookup'. "This is especially usefull in a loop where you call the function a zillion time" they say. I think this is very odd behavior.
9
7026
by: Koen | last post by:
Hi all, My application uses a lot of lookup tables. I've splitted the frontend (forms, reports, etc) from the backend (data). The database has around 10 different users. The values in the lookup tables are not likely to change. Question 1: Should I include them in the backend (with rest of data) or the frontend?
3
2912
by: my-wings | last post by:
I've been reading about how evil Lookup fields in tables are, but I've got to be missing something really basic. I know this subject has been covered before, because I've just spent an hour or two reading about it on google, but there is something I still don't understand, and I'm hoping someone will be willing to explain it to me in small words. Let's say I have a table for addresses, and it includes a field for state. What I would...
3
10628
by: google | last post by:
I have a database with four table. In one of the tables, I use about five lookup fields to get populate their dropdown list. I have read that lookup fields are really bad and may cause problems that are hard to find. The main problem I am having right now is that I have a report that is sorted by one of these lookup fields and it only displays the record's ID number. When I add the source table to the query it makes several records...
4
2581
by: Wiktor Zychla | last post by:
In my code I have to query the local dns server for some data. however, I have no idea how to get the name of the local DNS server. could anyone point me the right direction? thanks in advance, Wiktor Zychla
13
5583
by: paul.joseph.davis | last post by:
Hi, I've just had my first encounter with two-phase lookup and I'm scratching my head a bit. The idea behind two phase look up is pretty easy to understand, but I have a case that fails to compile although it appears to me that it should. template<typename TYPE> void foo( std::map< int, TYPE pmap )
0
1680
by: Chuckk Hubbard | last post by:
The docs say to try to discover the URI on my own if this happens. Could I get a hand doing that? This isn't just something I want to solve on my machine, e.g. by changing my network setup or what not; this is a program I hope to distribute and I hope my users can avoid having to deal with this, because I suspect they won't. Thankye. Here's what I typed and what I got:
0
2371
by: Chuckk Hubbard | last post by:
OK, I think I have it. The Manual says to start a Name Server "using the ns command", and I figured out that means using the pyro-ns script. On Mon, Nov 10, 2008 at 10:49 AM, Chuckk Hubbard <badmuthahubbard@gmail.comwrote: --
11
3984
by: ianoble | last post by:
I've been trying to piece together various code snippets to create a lookup table inside my xslt without the need for a supplemental xml file. Here is what I have so far. As of now, it does not return anything in the output. I would love to be able to query the xref:factor table to retrieve the value of xref:factor/lookup <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE xsl:stylesheet > <xsl:stylesheet...
1
2280
by: joeino | last post by:
I want to do a lookup query and append the record to a history table before editing the data. I created a macro to run the lookup query to append the record to history and it works fine. I did the same with the lookup query that allows the user to edit the record. I then converted them to vb and combined them. Code follows. My thinking is to create a variable dim keyno longint then pass keyno to the lookup queries. I am kind of new...
0
8256
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
8694
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8635
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...
1
8356
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7184
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...
1
6118
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5570
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
4089
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...
1
2621
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

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.