What is SimpleDNS?
SimpleDNS is an open source library which queries a DNS server of your choice and maps the received values to an object. It was designed with ease in mind as well as giving the developer the option to drill down into results similar to how a DNS packet is viewed in a tool like Wireshark. It’s been built to the standard proposed in the official RFC and the code has many references to certain sections of the RFC to aid other developers who wish to work on the project.
What makes SimpleDNS different to other DNS libraries?
You can work with a DNS packet (Send/Receive) using OOP and the DNS results like the Flags in the header (Response, Opcode, Authoritative etc…) are all shown as immutable properties. Basically, you don’t just get the result, you get the whole packet parsed into an object.
Okay…so how do I use it?
It’s simple, you can either create a DNS packet manually used for sending which will then return a new object instance with results, or you can use the simple custom SimpleDNS model which in the background creates a
DNSPacket using your values from the SimpleDNS model.
SimpleDNS Model Example:
//Create your question - (Hostname,QueryType) var question = new Question("i.stack.imgur.com", QType.A); //Create your SimpleDnsPacket and pass to the Util method Kitson.Dns.Query var result = Query.SimpleDnsAsync(new SimpleDnsPacket(question, IPAddress.Parse("126.96.36.199")));
Core DNS Model Example:
//DNS Header UInt16 transactionId = 200; IParameters parameters = new SendParameters(OPCode.Standard, true, false); UInt16 questionsCount = 1; UInt16 answersCounts = 0; UInt16 authority = 0; UInt16 additional = 0; //DNS Question var question = new Question("i.stack.imgur.com", QType.A); //DNS Header Construction IDnsHeader header = new DnsHeader(transactionId,parameters,questionsCount, answersCounts,authority, additional); //SendDnsPacket Construction SendDnsPacket packet = new SendDnsPacket(header, question); //Finally...Send your packet to the chosen DNS Server var result = Query.Dns(packet, IPAddress.Parse("188.8.131.52"));
And the results returned from the query above can be seen below…
CName Record Result:
A Record Result:
Does it work with .NET Core?
Yes. It’s compatible with .NET Core 2.0.
How can I download it?