I have written (not all by me!) a DNS server/daemon in Perl. It currently implements A, NS, MX, and CNAME lookups. It also does remote queries if configured to do so. I am currently adding reverse-DNS support for it, so that it can look up entries by IP address. If you really want to test it on your own computer, set it to listen on port 53 and fire up your web browser! Plus it also handles BIND's /var/named zone files!

Check out the code and more info here

Comments, criticisms, suggestions, bugs?

Replies are listed 'Best First'.
Re: dns server in perl
by JPaul (Hermit) on Feb 08, 2002 at 05:02 UTC
    Greetings,

    I have also embarked on a similar project.
    BIND is bloated, memory management was not a programming priority apparently, and its cache design is laughable. Asides from that its works fine. :)
    DJBDNS is another kettle of fish - its FAST, its pretty secure, and its smart -- But DJB has this really nasty habit of deciding all/part of an RFC is "stupid" and just doesn't bother implementing it, to hell with anyone else who actually expects DNS servers to be RFC compliant.

    My server also uses Net::DNS, however its somewhat more expansive with "intelligent caching" (self lookups when load is low on his tasks, dropping off least used cache entries when the cache is full, that kind of stuff), the zones are SQL based and centralised, removing the requirement for zone transfers, dig their own root servers, random junk.
    Works REALLY nice, except Net::DNS is painfully slow, which makes it quite useless in practice. Net::DNS is written entirely in perl, which is wonderful for educational purposes, but unfortunately pointless for real service - and Net::DNS hasn't been touched in a few years, if I remember correctly... Oh well

    Anyone want to rewrite Net::DNS, and this time in C? :P

    JP,
    -- Alexander Widdlemouse undid his bellybutton and his bum dropped off --

      I agree, Net::DNS is slow. dnsd's caching is _really_ primitive, and was/is just a hack until I implement some more features, like a better cache system, a "real" place to keep zone files in, etc. My main focus currently is a DNS server that can be used for serving domain names (authoritative servers for domains) and then I plan to extend it to implement remote queries and some optimizations that crazyinsomniac has made me aware of.

      What are you using to write your DNS server? Are you using Net::DNS modules to parse the message? or do you have some other and faster way of parsing the DNS query?

        Greetings,
        Yep, all the packet work and the outside query lookups are done by Net::DNS.

        I'm not entirely sure (Admittedly, I've never really gone into that much detail to debug) WHAT it is precisely that Net::DNS takes so long with, whether its the outside lookups, or the packet work.
        After caching an object, I can return it back very quickly (as is the point), so I don't think the basic packet disassembly/reassembly functions are particularly slow - I'm pretty sure the problem is mostly in the query/send/search functions.

        JP,
        -- Alexander Widdlemouse undid his bellybutton and his bum dropped off --

      The 'core' file in that directory isn't very encouraging ;p But seriously, its a great thing to get a functioning dns server writing in perl -- since customizing such a thing to work with some type of custom management system would be considerably easier. - Jon
Re: dns server in perl
by Rhandom (Curate) on Feb 08, 2002 at 16:43 UTC
    Sounds like there may be some duplication. Net::DNSServer already exists. It doesn't do the zone files. But it is fairly stable and handles DNS very well. It is also fully object oriented so it is very extensible. Haven't looked at yours, but it seems as if finer points from both could be merged.

    my @a=qw(random brilliant braindead); print $a[rand(@a)];
      Greetings again,

      Net::DNSServer is particularly limited, requires you write your own resolver of local domains ANYWAY (if you intend to be authoritative, instead of just a cacher) and it didn't even work on the three machines I tried.
      It inherits a whole STACK of functions making debugging work a depressingly bleak prospect.

      Plus mine is a whole lot smarter anyway ;)

      JP,
      -- Alexander Widdlemouse undid his bellybutton and his bum dropped off --