A simple DNS server for Windows with C# and .NET

Posted: (EET/GMT+2)

 

Lately, I've been involved in a project that utilizes an embedded device with web access. In this particular case, the device retrieves control information from the Internet, and my task is to intercept that data flowing to and from the device.

Now, part of the solution is to work with custom DNS records. The device sits however in a workstation environment, and there is no real Windows server machine running. With Windows Server, I could simply set up a DNS server with custom records, and configure the device to use this server to query IP addresses. Problem solved.

But, with only Windows 7 client available for the job, I went on to see if there were easy-to-download DNS servers for Windows 7. Turns out that it's a very limited marked, with only a couple of Linux ports available, plus some commercial ones.

So, what is a developer to do? Write his/her own DNS server, of course. Since there are several nice .NET libraries already available on the Internet, I chose to take one of these and write a simple WinForms wrapper around the library.

The result is a simple DNS server application that can respond to queries sent to it. By default, it forwards all request to the computer's configured default DNS server, and simply acts as a gateway. However, you can also specify a custom A record (IPv4 hostname lookup record) so that whenever a query for the IP address of a custom server name is requested, the server will respond with the IP address you specify.

The application can be seen in the following screenshot.

DNS Server for Windows

To download this free, simple DNS server for Windows 7 or Windows Server 2008, click here. The executable requires .NET Framework 4 runtime to be installed. Source code is available here.

Better networking!