tags:

views:

155

answers:

4

I have to implement a DNS server in C and I don't know where to start. What are all the features that a DNS has...how can I implement a bare-bones DNS in single C file.

I don't even want to use a Database, just a file will work.

Thank you in advance

+1  A: 

dns.net points up RFC 1034: DOMAIN NAMES - CONCEPTS AND FACILITIES and RFC 1035: DOMAIN NAMES - IMPLEMENTATION AND SPECIFICATION as the definitive references.

As a topical plus, wow your teacher by including some non-ascii IDN names in your toy lookup list.

Ewan Todd
These two RFC are *far* from being sufficient (2671, for instance, is really necessary today).And IDN requires no support for the name server so it will be purely for the demo effect.
bortzmeyer
A: 

The RFCs that the protocol is based on can be found here: http://www.zoneedit.com/doc/rfc/

There are also several explanations of the protocol that should be useful to be found around the internet, such as this one: http://www.windowsnetworking.com/articles_tutorials/Understanding-DNS-Protocol-Part1.html

Jason
+1  A: 

DNS is a big spec. If you really want DNS, use a DNS server. So if you want something really quick and dirty, why not just write a program that edits your hosts file (C:\windows\system32\drivers\etc\hosts or /etc/hosts (on UNIX)?)

Dave Markle
+3  A: 

That's big for homework! Your teacher is ambitious. Implementing DNS requires reading at least ten complicated RFC (not mentioning DNSSEC...) Do not limit yourself to RFC 1034 and 1035, there are mandatory RFC after (such as 2181 and 2671). See a nice graph of them.

Is it an authoritative name server or a recursive one?

Do you have to do it from scratch? If not, I strongly suggest to start with the evldns library, which allows you to write an anthoritative name server in 200 lines of C.

Otherwise, the usual advice applies: read source code (I suggest nsd for an authoritative server and unbound for a recursive one).

bortzmeyer