Creating and working with a names (DNS) server

A Names server can be perform three basic operations:

Creating a non-authoritative server

The first two of these are easy, and you can create a server that performs them with the command mktap dns --recursive --cache, or launch tkmktap and configure a dns server with it. The result should be a file named dns.tap. Now switch to a superuser account (if required by your platform to bind to port 53) and run twistd -f dns.tap. The Application will run and bind to port 53. Try performing a lookup with it, dig twistedmatrix.com @127.0.0.1.

Creating an authoritative server

To act as the authority for a domain, two things are necessary: the address of the machine on which the domain name server will run must be registered as a nameserver for the domain; and the domain name server must be configured to act as the authority. The first requirement is beyond the scope of this howto and will not be covered.

To configure Names to act as the authority for example-domain.com, we first create a zone file for this domain.

zone = [
    SOA(
        # For whom we are the authority
        'example-domain.com',

        # This nameserver's name
        mname = "ns1.example-domain.com",

        # Mailbox of individual who handles this
        rname = "root.example-domain.com",

        # Unique serial identifying this SOA data
        serial = 2003010601,

        # Time interval before zone should be refreshed
        refresh = "1H",

        # Interval before failed refresh should be retried
        retry = "1H",

        # Upper limit on time interval before expiry
        expire = "1H",

        # Minimum TTL
        minimum = "1H"
    ),

    A('example-domain.com', '127.0.0.1'),
    NS('ns1.example-domain.com', 'example-domain.com'),

    CNAME('www.example-domain.com', 'example-domain.com'),
    CNAME('ftp.example-domain.com', 'example-domain.com'),

    MX('example-domain.com', 0, 'mail.example-domain.com'),
    A('mail.example-domain.com', '123.0.16.43')
]

Next, run the command mktap dns --pyzone example-domain.com, and then (as above) twistd -f dns.tap. Now try querying the domain locally (again, with dig): dig -t any example-domain.com @127.0.0.1.

Names can also read a traditional, BIND-syntax zone file. Specify these with the --bindzone parameter. The $GENERATE and $INCLUDE directives are not yet supported.

Index

Version: 1.3.0