From: Xan Date: 2006-04-17T02:48:01+09:00 Subject: Re: authoritative only DNS in ruby Sam Roberts wrote: > On Thu, Apr 13, 2006 at 12:48:41AM +0900, Xan wrote: >> An alternative is if you point me some library that serve for receiving >> UDP packets of client DNS and can process these > > Look at the source for resolv.rb in the ruby stdlib. It has DNS message > encoding/decoding classes. > > Also, the dnssd project has a net-mdns project with a forked version of > resolv.rb with bug fixes, documentation, and extensions to resolv.rb you > might find useful: > > http://dnssd.rubyforge.org/net-mdns/ > > An mDNS/DNS-SD server receives and sends DNS format messages, so might > be a useful example for you if you are writing a mini pure-ruby DNS > server. The message encoding and decoding should be pretty easy, and I > should be able to help if you have trouble. > First of all, thank you very much for your answer and for point me these two resources. It's a good start point. In the same time you answer me, I see the rfc1035 specifications for showing what parts of DNS I need for this project (it's obvious that I don't need all DNS: only local, the foreign part (recursive search) is not needed)) and I came crazy: too low-level specifications for implementing on scratch in reasonable time. It's good you point me these high-level classes. > Also, I'd be interested in seeing your code if you publish, it could be > very interesting to have a DNS server framework in ruby. There might be > some synergy between it and DNSSD. For example, I might be able to point > nameserver in my resolv.conf to 127.0.0.1, and have a ruby DNS daemon > runnning that did lookups in .local using mDNS and forwarded all other > lookups to the "real" DNS server. If you structure your DNS server in a > way that records can be added to it at runtime (so not just load them > from a static file, perhaps have it make callbacks for record lookups), > maybe I could use it, too. :-) On one hand, obviously I publish the code ;-). I want that all can benefit of it. If the try is, in future, successfully, probably I will license in GPL. On the other, your idea is essentially what I want to do: - My original idea was to write a class nameserver, say NS for short, and putting it in /etc/resolv.conf as third DNS resolver. NS has a file in which we share hosts we want to remember. For example: # ip | alias 127.0.0.1 localhost.localdomain 72.14.207.99 google.com 214.52.69.56 myfriendoscar 127.0.0.6 epsilon.localdomain and that any user could write to this file with another ruby class that passes to NS the host-ip for saving in this file. No recursive search of unknown host are allowd The idea was begin to code first only a DNS without user intervention. This is why I put the idea of authoritavie only DNS in ruby in the ruby-talk - If I understood well, you idea is a bit different: write a local DNS and put it in resolv.conf. This local DNS has some database of known hosts. Any user without shell could add host to this database. In the moment of resolv a name, this local DNS see this database. If the host appears in that, then DNS returns the ip. If not, DNS request external DNS's answer. With the interaction of the users and DNS we could have for example great things: for example answer to one user that epsilon.localdomain is 127.0.0.6 and another that we don't know that (that is, user privileges). I think it's a good thing Frankly, I see that in a more long term time, because I'm a newbee of ruby (I know something of java) (I'm not a programmer) and because all code of DNS that I looked is very long (so I suspect it's not easy thing to do and more with enhancements) If you can help me I thank you very much. I need, overall, that you point me in the main lines of the project, overall, how can I write a simply DNS that get the ip of one specific hosts and returns that it does not know any other host ip. Another time, thank you very much, Xan. PS: Maybe it were better pass to private communication PPS: Sorry my poor english > > Good luck, > Sam -- Posted via http://www.ruby-forum.com/.