A (writable) DNS filesystem

December 6, 2010

dns

I’ve extended the DNS filesystem a bit and added the possibility to WRITE to it. This only works for zones which utilize dynamic updates.

You can now mount the world and write to it!

Also TSIG should be supported (but I have not tested it - as I’m lazy). For TSIG you need a file (named “dynupdate” here with the following):

# domain           tsig-key name       key
miek.nl            tsig-key            awwLOTrFPge+rRKF2+DEiw==

Code is still contained in a single Perl file.

I’ve create a dynamic zone for dyn.miek.nl, so lets see how it works:

$ ./dns.pl dynupdate theworld       # start our filesystem
$ cd NL/MIEK/
$ ls
a  mx  ns  soa  txt
$ cat txt
MIEK.NL.    86400   IN  TXT "$Hash: edf130d 2010-08-25 08:29:16 +0200 Miek Gieben$"
## So far nothing new

Now lets write:

$ cd DYN
$ ls
a  mx  ns  soa  txt
## We have a name: dyn.miek.nl with the following addresses:
$ cat a         # show the a-records dyn.miek.nl
DYN.MIEK.NL.    4000    IN  A   127.0.0.2
DYN.MIEK.NL.    4000    IN  A   127.0.0.1
## Lets add another
$ echo "dyn.miek.nl 4000 IN A 127.0.0.3" > a   
$ cat a
DYN.MIEK.NL.    4000    IN  A   127.0.0.3
DYN.MIEK.NL.    4000    IN  A   127.0.0.2
DYN.MIEK.NL.    4000    IN  A   127.0.0.1

It does not really matter what filename you use, because it currently looks only at the content you write.

# adding new name: c.dyn.miek.nl
$ echo "c.dyn.miek.nl 30 IN A 127.0.0.1" > a    # note: still "a"
# cat C/a    # show the a-record in the directory C
C.DYN.MIEK.NL.  30  IN  A   127.0.0.1
#
# Perform an illegal write:
$ echo "miek.nl 30 IN A 127.0.0.1" > a  # isn't a dynamic zone
echo: write error: invalid argument

Things you might want to add to this code:

  • with mkdir create a delegation (easy: just add NS records);
  • with rmdir delete a delegation;
  • with unlink delete records;
  • Anything else you can think of;
  • Again: the code.
None