[aklug] Re: DNS TXT Record

From: Royce Williams <royce@tycho.org>
Date: Sun Nov 21 2010 - 15:32:01 AKST

Kevin Miller said, on 11/19/2010 07:59 AM:
> On 11/18/2010 09:41 PM, Christopher Howard wrote:
>> My DNS provider allows me to set a TXT record for my zone. I was just curious: can I put whatever I want in that field? Googling indicated the field was originally meant to be a field with a human-readable message, but later on got used for other stuff.
>
> I believe you can. Most commonly probably you'll see it used for SPF
> records.
>
> One thing to watch however is the length. Don't recall what it is, but
> I remember reading that it's bit people. IIRC some DNS servers limit
> the size to 512 bytes or something like that, unless specifically set
> larger...

I dug around briefly in the code but couldn't quickly find it, so I did an empirical test.

On my BIND 9.4 box, TXT records larger than 256 bytes cause the zone to fail to load. Here's the maximum record I could use:

testtest2=12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345

However, you can have multiple TXT records. Your app could interpret them as continuations of the previous, if you give them a sequence number or something. Depending on what clients you expect to consume the information, there are also practical limits based on DNS UDP response sizes which will make a query fail over to a TCP DNS lookup (note the "Truncated, retrying in TCP mode"):

royce@heffalump$ host -t txt prv.tycho.org 127.0.0.1
;; Truncated, retrying in TCP mode.
Using domain server:
Name: 127.0.0.1
Address: 127.0.0.1#53
Aliases:

prv.tycho.org descriptive text "testtest4=12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345"
prv.tycho.org descriptive text "testtest5=12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345"
prv.tycho.org descriptive text "testtest0=12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345"
prv.tycho.org descriptive text "testtest1=12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345"
prv.tycho.org descriptive text "testtest2=12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345"
prv.tycho.org descriptive text "testtest3=12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345"

In general, I like the idea of using TXT for storing arbitrary attributes (RFC1464). SPF and DomainKeys take this route.

A while back, I hit upon the idea of using TXTs to store the RCS "Id" tag for my zones, and a couple of other random items:

royce@heffalump$ host -t txt tycho.org | sort
tycho.org descriptive text "ASN=7782"
tycho.org descriptive text "TC-email=royce@alaska.net"
tycho.org descriptive text "TC-name=Royce Williams"
tycho.org descriptive text "TC-phone=907-522-7478"
tycho.org descriptive text "rcsvers=$Id: db.tycho.org.shared,v 1.9 2010/10/11 01:09:58 root Exp $"
tycho.org descriptive text "v=spf1 ip4:209.112.173.224/27 mx include:acsalaska.net include:gmail.com ~all"

The "TC-" ("technical contact") convention is long dead, but I keep it in homage to another time. I piped it through "sort" because most servers return them in a changing order. BIND 9 round-robins them, like it does for some other record types.

Another fun one is HINFO -- not used by anybody anymore but still usually supported. Potentially useful for categorizing internal hosts, if you can figure out how to not leak the information out the public side.
  
royce@heffalump$ host -t hinfo testhost.tycho.org
testhost.tycho.org host information "i386" "Mostly Unix-like"

( ... with apologies to Douglas Adams' "Mostly harmless")

A useful reference:

    http://en.wikipedia.org/wiki/List_of_DNS_record_types

Royce
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Sun Nov 21 15:32:05 2010

This archive was generated by hypermail 2.1.8 : Sun Nov 21 2010 - 15:32:06 AKST