开发者

A bare-bones DNS server

I have to im开发者_如何学Cplement 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


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).


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)?)


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.


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


This should get you started.

This example uses BSD sockets to build a simple DNS resolver. http://www.binarytides.com/blog/dns-query-code-in-c-with-winsock-and-linux-sockets/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜