The OpenNET Project / Index page

[ новости /+++ | форум | wiki | теги | ]

Поиск:  Каталог документации / Документация по FreeBSD / Руководства по FreeBSD на английском

Chapter 6. Exercises for the Interested Student

Table of Contents
6.1. Creating a mini-DNS system
6.2. Playing with PPP filters

6.1. Creating a mini-DNS system

While managing a Domain Name Service (DNS) hierarchy can be a black art, it is possible to set up a Mini-DNS server on the FreeBSD system that also acts as your gateway to your ISP.

Building on the files in /etc/namedb when the FreeBSD system was installed it's possible to create a name server that is both authoritative for the example network shown here as well as a front-door to the Internet DNS architecture.

In this minimal DNS configuration, only three files are necessary:


The /etc/namedb/named.root file is automatically installed as part of the FreeBSD base installation; the other two files must be created manually.

6.1.1. The /etc/namedb/named.boot file

The /etc/namedb/named.boot file controls the startup settings of the DNS server. Esentially, it tells the Name Server:

  1. Where to find configuration files,

  2. What "domain names" it's responsible for, and

  3. Where to find other DNS servers.

Using the 'ee' editor, create a /etc/namedb/named.boot with the following contents:

    ; boot file for mini-name server
    directory   /etc/namedb
    ; type    domain        source host/file        backup file
    cache     .         named.root
    primary   my.domain.        mydomain.db

Lines that begin with a semi-colon are comments. The significant lines in this file are:

  • directory /etc/namedb

    Tells the Name Server where to find the configuration files referenced in the remaining sections of the '/etc/namedb/named.boot' file.

  • cache . named.root

    Tells the Name Server that the list of "Top-Level" DNS servers for the Internet can be found in a file called 'named.root'. (This file is included in the base installation and its contents are not described in this document.)

  • primary my.domain. mydomain.db

    Tells the Name Server that it will be "authoritative" for a DNS domain called "my.domain" and that a list of names and IP addresses for the systems in "my.domain" (the local network) can be found in a file named 'mydomain.db'.

Once the /etc/namedb/named.boot file has been created and saved, proceed to the next section to create the /etc/namedb/mydomain.db file.

6.1.2. The /etc/namedb/mydomain.db file

The /etc/namedb/mydomain.db file lists the names and IP addresses of every system in the Local Area Network.

For a detailed description of the statements used in this file, refer to the named manpage.

The /etc/namedb/mydomain.db file for our minimal DNS server has the following contents:

    @  IN SOA  my.domain.  (
                    961230  ; Serial
                    3600    ; Refresh
                    300 ; Retry
                    3600000 ; Expire
                    3600 )  ; Minimum
        IN NS    IN A # The FreeBSD box    IN A # The Win'95 box      IN A # The WfW box    IN A # The Windows NT box
    $ORIGIN 1.168.192.IN-ADDR.ARPA
            IN NS
    1       IN PTR
    2       IN PTR
    3       IN PTR
    4       IN PTR
    $ORIGIN 0.0.127.IN-ADDR.ARPA
            IN NS
    1       IN PTR

In simple terms, this file declares that the local DNS server is:

  • The Start of Authority for ("SOA") for a domain called 'my.domain',

  • The Name Server ("NS") for 'my.domain',

  • Responsible for the reverse-mapping for all IP addresses that start with '192.168.1.' and '127.0.0.' ("$ORIGIN ...")

To add workstation entries to this file you'll need to add two lines for each system; one in the top section where the name(s) are mapped into Internet Addresses ("IN A"), and another line that maps the addresses back into names in the $ORIGIN 1.168.192.IN-ADDR.ARPA section.

6.1.3. Starting the DNS Server

By default the DNS server ('/usr/sbin/named') is not started when the system boots. You can modify this behavior by changing a single line in '/etc/rc.conf' as follows:

Using the 'ee' editor, load /etc/rc.conf. Scroll down approximately 40 lines until you come to the section that says:

    named_enable="NO"                       # Run named, the DNS server (or NO).
    named_flags="-b /etc/namedb/named.boot" # Flags to named (if enabled).
Change this section to read:
    named_enable="YES"                      # Run named, the DNS server (or NO).
    named_flags="-b /etc/namedb/named.boot" # Flags to named (if enabled).
Save the file and reboot.

Alternatively, start the Name Server daemon by entering the following command:

    # named -b /etc/namedb/named.boot

Whenever you modify any of the files in /etc/namedb you'll need to kick-start the Name Server process to make it pick up the modifications. This is performed with the following system command:

    # kill -HUP `cat /var/run/`

For questions about FreeBSD, e-mail <>.
For questions about this documentation, e-mail <>.

Inferno Solutions
Hosting by

Закладки на сайте
Проследить за страницей
Created 1996-2020 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру