简体   繁体   中英

Two questions about DNS resolution using [System.Net.Dns]: how does it work and what port does it use?

1 - How does it work? This question has come up because I am working with a guy for whom the call to System.Net.Dns.GetHostAddresses does not work. I gave him a sample app that just calls the aforementioned method and displays the IP addresses that are returned. Here is his explanation after using it:

When I try to resolve www.google.com [in the app] it does not work on the local workstations, because our internal DNS do not resolve external DNS names. [But] If I put www.google.com in the browser, the proxy server knows to go to the external DNS servers for name resolution and it resolves the name to the IP address. Even if we put the proxy server name in the application it does not work when testing the resolution.

I have done some packet sniffing on my work computer (which has a proxy server) and my personal computer (which does NOT have a proxy server) and there seem to be no packets sent or received durring the GetHostAddresses call.

2:

What port number is used?

Also asked by the person I am working with. I have no idea about this one. If there are no packets sent then it seems the answer would be there is no port being used, but I am not very savvy when it comes to ports and things like this.

DNS is a huge subject. Concerning Q1, it depends on how your machine is configured (node type). Googling on this should help you on the general principles.

Here is an answer about the ports: Network Ports Used by DNS

The reason in browser works and in command prompt does not is that browser has been setup to use a proxy and command prompt is not.

In order to see what code is used, use reflector. I have been told off to post any Microsoft code but I looked at the code and it was mainly unsafe and Win32 API calls.

The reason you're not seeing any network traffic when you use the packet sniffer could be that google.com is already in your local client DNS cache. If your browser has resolved it, it'll be in the cache. Try ipconfig /flushdns from the command line, and then use nslookup again to resolve google.com. I think you'll see some network traffic then.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM