Sam Trenholme of MaraDNS fame has updated his "world's smallest useful DNS server". It is so small, that the code fits right here:

/*Placed in the public domain by Sam Trenholme*/
    #include <arpa/inet.h>
    #include <string.h>
    #include <stdint.h>
    #define Z struct sockaddr
    #define Y sizeof(d)
    int main(int a,char **b){uint32_t i;char q[512]
    1){struct sockaddr_in d;socklen_t f=511;bzero(&
    16);sendto(a,q,i+16,0,(Z*)&d,Y);}}}return 0;}

Compile it (cc nanodns.c) and run it (./a.out as root. It binds to all the machine's interfaces and returns the IP specified on the command line as an A resource record to any query it gets. The code is a little obfuscated, but it works.

Flattr this
DNS and CLI :: 05 Aug 2010 :: e-mail


blog comments powered by Disqus