سؤال

nslookup google.co.kr IP results change whenever I tried this command

But in C#, using method GetHostEntry() in library System.Net.Dns, I got always same results.

I wanna know why this phenomenon has been occured and whether I can get same reuslt as nslookup using GetHostEntry.

هل كانت مفيدة؟

المحلول

When you call GetHostEntry() you will get whatever data is in the local DNS cache. If the hostname has not been retrieved recently it will query the DNS servers to get the information. The NSLOOKUP command will query the DNS servers every time, ignoring whatever might be in the local cache. This might result in the same data coming back over and over, depending on the caching at your DNS server.

For most simple DNS results, you'll get the same data every time. For clustered services that are hosted on groups of servers - such as google - the results will be chosen by the google DNS servers based on loading and so on. In cases like that you can get different results from successive invocations of NSLOOKUP, but GetHostEntry() will return the same results until the entry expires from the local DNS cache.

DNS caching helps reduce loading on the DNS servers as well as reducing network traffic. Unless you need a different set of results each time, GetHostEntry() will be faster and more efficient.

نصائح أخرى

When you I used GetHostEntry() I noticed that this function does not support DNS records from type CNAME and throws an exception. nslookup supports DNS records from type CNAME.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top