qpdcdg
Last Updated: February 25, 2016
·
1.601K
· ioquatix

Make your own crazy DNS server!

I wanted to share a gem I made and I've got a fun demonstration.

I was always interested in DNS clients and servers and at one point I had a very specific setup with servers behind an ADSL NAT connection, which meant that locally resolved names pointed to servers inside the NAT while externally resolved names should point at the ADSL modem which had appropriate VHOST rules. Thus, was born RubyDNS.

RubyDNS is an infinitely flexible DNS server which includes an asynchronous DNS client to ensure non-blocking behaviour when forwarding requests upstream. It is built on EventMachine which theoretically should provide a good asynchronous foundation for processing DNS requests and integration with other asynchronous systems (e.g. em-http-request).

For fun, I made an example. WikipediaDNS allows you to query wikipedia via DNS, e.g.:

^_^ > dig +tcp +short @ayako.oriontransfer.org computer.wikipedia TXT
"A computer is a general purpose device that can be programmed to carry out a finite set of arithmetic or logical operations. Since a sequence of operations can be readily changed, the computer can solve more than one kind of problem."

I'm running it on my VPS (temporarily for this demonstration, don't expect this to be a permanent home) and you can also run it locally, the code is available: https://github.com/ioquatix/rubydns/blob/master/test/examples/wikipedia-dns.rb - in this example, I've forced +tcp as udp seems to be blocked, at least from my current location.

RubyDNS has been used in a number of interesting systems, including Murakumo, a distributed peer-to-peer DNS system, and along side vagrant to provide dynamically registered DNS names for dynamically created virtual hosts. Someone also contacted me recently about using it for full scale network integration testing and also browser level testing of some sort. It was used in f***PSN, a tool for bypassing the PSN network, and has been also used in SiriProxy (I'm sure you can guess what it does).

I'd love to share RubyDNS with the hope that I see more interesting projects developed on top of it. I get really excited thinking about all the possibilities. For example it would be really interesting to make a client-server architecture for sending data via DNS, perhaps some kind of DNS port knocking security system, better integration of information systems with DNS (e.g. mapping "document database" to DNS records).

Source code is available: https://github.com/ioquatix/rubydns

Project home page with introduction video and documentation: http://www.codeotaku.com/projects/rubydns/index.en