20

I am developing a very basic DNS server for my own purpose. The way I understand it, the DNS server receives UDP packets containing the requested domain name and returns the corresponding IP under some kind of standard form.

There is a standard library for reading/writing UDP packets from/to binary format. But where can I find a C# library for serialising/deserialising DNS requests/responses?

Régis B.
  • 10,092
  • 6
  • 54
  • 90
  • You can check the following set of NetKit .NET classes that makes the work of DNS servers http://www.thedownloadplanet.com/reviews/netkit-component-for-net/ – alexanoid Jul 01 '18 at 17:43

3 Answers3

18

The open source ARSoft.Tools.Net library contains a DNS Server component (see documentation).

You could use this library directly, or just use the source as a starting point for building your own DNS request serializer.

Chris Shouts
  • 5,377
  • 2
  • 29
  • 40
4

As far as I can tell, I couldn't find a library for C# which handles DNS packet serialization/deserialization, which means it's likely you'll have to roll your own.

Edit: I came across this network packet sniffer project on Code Project which might have what you need. Claims to be able to to parse TCP/UDP/DNS

I did find this very helpful site for TCP/IP which has a pretty comprehensive set of pages describing DNS packet types including the general message format.

There might be some additional help from this previous SO question though.

Community
  • 1
  • 1
RobS
  • 9,382
  • 3
  • 35
  • 63
3

If you look at wikipedia you find a list over all RFC's for the dns protocol, i find rfc's to be the best way to implement a network protocol!

now the dns protocol has rather many rfc's so i dont know if this is the best way to read up on the protocol but you get all the information you need atleast.

http://en.wikipedia.org/wiki/Domain_Name_System#Internet_standards

Peter
  • 37,042
  • 39
  • 142
  • 198
  • 1
    I did find myself implementing the RFC recommendations before I tried out the ARSoft library. More specifically, I used sections 4.1.1 and following of: http://tools.ietf.org/html/rfc1035 – Régis B. Jan 13 '11 at 08:56