Storing ASCII art in the DNS

From time to time, I like to do some quick DNS related experiments, and storing ASCII art in the DNS had been on my idea list for quite a while.

The naive approach to this problem would be to simply use TXT records, but there are a couple of issues with this method. First, it’s not possible to specify the order of priority of TXT records, and results seem to vary depending on implementations. But moreover, there is no way to have several times the exact same line, as the records would be identical and only one would be taken into account when parsing the zone.

On the other hand, NAPTR records look like the perfect candidates for this purpose, as they can be ordered using the Order and Preference fields (see RFC 2915, for the NAPTR RR Format).

For this experiment, the first ASCII diagram from RFC 1035 will be used.

Here is the content of the zone :

ascii NAPTR 100 10 "" "              Local Host                        |  Foreign    " "" .
ascii NAPTR 110 10 "" "                                                |             " "" .
ascii NAPTR 120 10 "" " +---------+               +----------+         |  +--------+ " "" .
ascii NAPTR 130 10 "" " |         | user queries  |          |queries  |  |        | " "" .
ascii NAPTR 140 10 "" " |  User   |-------------->|          |---------|->|Foreign | " "" .
ascii NAPTR 150 10 "" " | Program |               | Resolver |         |  |  Name  | " "" .
ascii NAPTR 160 10 "" " |         |<--------------| 10="" 170="" 180="" 190="" 200="" 210="" 220="" 230="" 240="" |<--------|--|="" server="" |="" "="" ""="" .="" ascii="" naptr="" user="" responses|="" |responses|="" +---------+="" +----------+="" +--------+="" a="" cache="" additions="" references="" v="" <="" pre="">

And the result of querying the zone for NAPTR records :

dig ascii.statdns.org naptr +short
;; Truncated, retrying in TCP mode.
100 10 "" "              Local Host                        |  Foreign    " "" .
110 10 "" "                                                |             " "" .
120 10 "" " +---------+               +----------+         |  +--------+ " "" .
130 10 "" " |         | user queries  |          |queries  |  |        | " "" .
140 10 "" " |  User   |-------------->|          |---------|->|Foreign | " "" .
150 10 "" " | Program |               | Resolver |         |  |  Name  | " "" .
160 10 "" " |         |<--------------| 10="" 170="" 180="" 190="" 200="" 210="" 220="" 230="" 240="" |<--------|--|="" server="" |="" "="" ""="" .="" user="" responses|="" |responses|="" +---------+="" +----------+="" +--------+="" a="" cache="" additions="" references="" v="" <="" pre="">