Search code examples
asp.netazurednsmx-record

How to do DNS lookup in a Windows Azure web role?


I download DnDNS from http://dndns.codeplex.com/ and get it work at local IIS.

sample code:

request.Resolve("8.8.8.8", domain_a_string, NsType.MX, NsClass.INET, ProtocolType.Udp, null);

but on Windows Azure, not work, it says cannot connect to the DNS server, no response (or dropped)

Then, I tried 4.2.2.4 and plenty other public DNS server, none work.

Does anyone here have a working code or other DNS lookup solution for Azure?


Solution

  • I believe DNS works via UDP, and in Windows Azure, UDP traffic isn't routed. You'll need to use the DNS server inside Windows Azure. If there's a way with that library to just use the default DNS server Windows is configured to use, that should work. If not, you might derive some inspiration from http://smarxrole.codeplex.com/SourceControl/changeset/view/3accd48815c3, which is a PowerShell script that gets the right DNS server in Windows Azure.