How to create simple dns server in C programming language? Can someone provide the code? It may read some A or AAAA queries. Please help!!
7
6
u/DasSkelett Oct 26 '20 edited Oct 26 '20
Don't. Whatever the problem is, writing your own DNS server is definitely the wrong solution.
There are a lot of proven and established implementations out there, among them highly customisable and modular ones. Use them.
3
u/danielzn Oct 26 '20
Don’t do it. But if you want to just learn you can start here.
https://labs.ripe.net/Members/bert_hubert/introducing-tdns-the-teachable-authoritative-dns-server
2
u/kevin_k Oct 26 '20
I'd look at tcp/ip illustrated vol 1 (for an idea of the data structures involved in a query) and vol 2 (for general examples of reading/writing UDP)
1
u/mk5p Oct 26 '20
I agree with u/-Rabbit-. Having had to go down the rabbit hole myself early, trying to understand/troubleshoot the myriad of inconsistencies of DNS record/implementations as it relates to other companies/organizations' products and application servers is mind-boggling.
My advice would be to start with the old RFC's and move on from there to get a better perspective.
https://en.wikipedia.org/wiki/Request_for_Comments
Happy Monday! :)
1
1
u/komkil Oct 27 '20
There's a lot of info about DNS at Dan Bernstein's site: https://cr.yp.to/djbdns.html
It's also worth noting that he created this server as result of security holes in the standard server and resolver, nearly 20 years ago, in his own eclectic style
-5
10
u/-_Rabbit_- Oct 26 '20
you should not do this. DNS seems simple but the world is littered with terrible implementations that break all kinds of standards and cause problems for everyone. There are many many open source options that you can deploy and run that will do a far better job than you knocking together some code in your basement. You can even contribute to those projects if you want to help them along.