DNS Mischief

Michael Stone michael at laptop.org
Sun Jul 5 20:36:24 EDT 2009


As many of you know, I've been fascinated for some time by Scott's Network
Principles [1]. 

Several weeks ago, I outlined in a lightly-circulated patch how one might hack
up libc's getaddrinfo() implementation to do the DNS resolution work described
in Scott's paper.

Here is a second copy of that patch, which I have improved to the point where I
am willing to recommend it for further testing, adaptation, and exploration.

(This new version uses libcrypt's MD5 implementation in favor of pulling in
chunks of libtomcrypt and it includes the minimum knowledge of "gaih_service"
structs necessary to work with ssh, wget, etc.)

To build it, grab your distro's libc6 packaging, apply the patch to
sysdeps/posix/getaddrinfo.c, and make sure that you define 

   "crypt-in-libc = yes" 
   
in an appropriate configuration file. Then build normally. Some tests for
getaddrinfo() will fail but you should wind up with a fully functional
libc.so.6 which you may install or use via LD_PRELOAD like so:

   # calculate an address for "sonipes"
   LD_PRELOAD=/path/to/libc.so.6 python -c 'import socket; print socket.getaddrinfo("sonipes", None)'

   # suppose we get fe80::b3da:e0e7:3bd7:278d%eth0

   # on sonipes:
   sudo ip addr add fe80::b3da:e0e7:3bd7:278d%eth0 dev eth0

   # elsewhere, on another computer on the same link as sonipes
   sudo env LD_PRELOAD=/path/to/libc.so.6 ping6 sonipes
   LD_PRELOAD=/path/to/libc.so.6 ssh sonipes
   (rsync, wget, nc6, ...)

Enjoy,

Michael

[1]: http://wiki.laptop.org/go/Network_principles

P.S. - Improvements are definitely welcome -- I found the code very satisfying
to use on a local wireless network.

   a) provide a cute one-liner for assigning appropriate addresses to interfaces
      based on the machine's desired hostnames

   b) check the code for endian-neutrality

   c) figure out how to fully build and package the result for easier testing

   d) rewrite as an NSS module?

   e) rewrite in an external DNS resolver?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dns.diff
Type: text/x-diff
Size: 4788 bytes
Desc: not available
URL: <http://lists.laptop.org/pipermail/devel/attachments/20090705/964488bb/attachment.diff>


More information about the Devel mailing list