Creating and working with a names (DNS) server

A Names server can be perform three basic operations:

  • act as a recursive server, forwarding queries to other servers
  • perform local caching of recursively discovered records
  • act as the authoritative server for a domain

Creating a non-authoritative server

The first two of these are easy, and you can create a server that performs them with the command twistd -n dns --recursive --cache . You may wish to run this as root since it will try to bind to UDP port 53. Try performing a lookup with it, dig @ .

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 , we first create a zone file for this domain.

zone = [
        # For whom we are the authority

        # This nameserver's name
        mname = "",
        # Mailbox of individual who handles this
        rname = "",

        # 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('', ''),
    NS('', ''),

    CNAME('', ''),
    CNAME('', ''),

    MX('', 0, ''),
    A('', '')

Next, run the command twistd -n dns --pyzone . Now try querying the domain locally (again, with dig): dig -t any @ .

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.

Table Of Contents

Previous topic

A Guided Tour of twisted.names.client

Next topic

Creating a custom server

This Page