473,385 Members | 2,015 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,385 software developers and data experts.

How to get DNS Server IP address?

In windows, Dns.GetHostEntry invocation on a non-existent domain cost
time (about 25 seconds in my machine). So, I decide to implement my
own DNS resolution with UDP packet transfer.

One problem is that, how to get DNS server IP config for current
machine?
Thanks

Jun 17 '07 #1
2 13204
This is one way (but only in .NET 2.0):

<code>
using System.Net.NetworkInformation
....
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface ni in nics)
{
if (ni.OperationalStatus == OperationalStatus.Up)
{
IPAddressCollection ips = ni.GetIPProperties().DnsAddresses;
foreach (System.Net.IPAddress ip in ips)
{
MessageBox.Show(ip.ToString());
}
}
}

</code>
"Morgan Cheng" wrote:
In windows, Dns.GetHostEntry invocation on a non-existent domain cost
time (about 25 seconds in my machine). So, I decide to implement my
own DNS resolution with UDP packet transfer.

One problem is that, how to get DNS server IP config for current
machine?
Thanks

Jun 17 '07 #2
On Jun 17, 11:13 pm, Siva M <shiva...@online.excite.comwrote:
This is one way (but only in .NET 2.0):

<code>
using System.Net.NetworkInformation
...
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface ni in nics)
{
if (ni.OperationalStatus == OperationalStatus.Up)
{
IPAddressCollection ips = ni.GetIPProperties().DnsAddresses;
foreach (System.Net.IPAddress ip in ips)
{
MessageBox.Show(ip.ToString());
}
}

}

</code>

"Morgan Cheng" wrote:
In windows, Dns.GetHostEntry invocation on a non-existent domain cost
time (about 25 seconds in my machine). So, I decide to implement my
own DNS resolution with UDP packet transfer.
One problem is that, how to get DNS server IP config for current
machine?
Thanks
It works . thanks

Jun 18 '07 #3

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

Similar topics

12
by: tshad | last post by:
I am trying to run a test sending mail using CDONTS on my W2K3 machine. It works fine running from my WXP Pro, but I don't recieve the mail if run the W2K3 machine. Both machines have IIS...
3
by: Ellen K | last post by:
Hi all, We have standardized on Hyperion as our reporting tool. So far I have only set up a couple of Access databases as data sources for it. Now there is a request to report off our eOn...
10
by: Jim H | last post by:
I have a UDP socket that sends out a request on a multicast socket and waits for a response. This client is not listening on a multicast IP but the local IP. The server (UNIX) responds to the...
4
by: Bob H | last post by:
Hi, I'm aware of the different ways to pass variables between ASP.Net pages. For pages that need to pass a variable, we're using the server.transfer method. For others, we're using...
4
by: John Boy | last post by:
Hi, Can anyone help. This is really doing my nut in. 3 years ASP exp. and now doing .DOT which is a step in the wrong direction. Basically I am left with the code of a guy who has left. When I...
3
by: RFD | last post by:
I've been slaving at this problem for over a week, and would appreciate some help from you kind folks. Basic Problem: I have made a server program and a client program. When I try to use the...
1
by: eblackmo | last post by:
I have a test network consisting of four servers running windows 2003 server R2 SP2. I have set up a domain which functioned correctly for about a day and a half until the other servers decided they...
0
by: sarahnetworking | last post by:
Hello, I have developed a client server application using C. i have a list of usernames and a list of passwords in a text file. i need to be able to do 2 loops so i can send the usernames and...
1
by: andrew.smith.cpp | last post by:
Hello All :-), i last Posted a request about the spam at google and someone told me about PAN i install it on my PC but when i start it and the msg shows there is no server selected .and then i...
7
by: RN1 | last post by:
Is it possible to connect to my local SQL Server 2005 database from a remote web server? If yes, what ConnectionString do I use? Thanks, Ron
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
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...
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.