Installing A FreeBSD 7.0 DNS Server With BIND - Page 6
Creating the Master forward lookup zone file
Remember to replace tm.local with your domain name, it must match what you have used before.
So we will create the file tm.local:
cd /var/named/etc/namedb/master
ee tm.local
Then we add the following:
$TTL 3600 tm.local. IN SOA dnsfreebsd.tm.local. root.tm.local. ( 1 ; Serial 10800 ; Refresh 3600 ; Retry 604800 ; Expire 86400 ) ;Minimum TTL ; DNS Servers tm.local. IN NS dnsfreebsd.tm.local. ; Computer names and records dnsfreebsd.tm.local. IN A 192.168.0.2 ; Aliases www IN CNAME dnsfreebsd.tm.local. ; Mail MX Records tm.local. IN MX 10 dnsfreebsd.tm.local. |
Feel free to modify based on what you want to do, you can add more aliases, A or MX records, and make sure to change your domain name above from tm.local to your domain name and make sure to add a "." after words, also change your hostname from dnsfreebsd to the hostname you are using.
root.tm.local is the e-mail address of the person responsible for the zone, here we use a "." instead of an "@" sign.
Creating the Master reverse lookup zone file
Now we will create a reverse lookup zone file for the forward one we created above using the following commands:
cd /var/named/etc/namedb/master
ee tm.local.rev
Then we we will add the below data to it, again feel free to modify based on your configuration:
$TTL 3600 0.168.192.in-addr.arpa. IN SOA dnsfreebsd.tm.local. root.tm.local. ( 1 ; Serial 10800 ; Refresh 3600 ; Retry 604800 ; Expire 86400) ; Minimum TTL ; DNS Servers 0.168.192.in-addr.arpa. IN NS dnsfreebsd.tm.local. ; Computer IPs 100 IN PTR dnsfreebsd.tm.local. 100 IN PTR www.tm.local. |
Testing your DNS Server
Now we are finished with configuration, we just need to start the service and test it.
First of all let's make sure that your server has it's own IP as the primary DNS server in the resolv.conf file.
Open the resolv.conf:
ee /etc/resolv.conf
and make sure you are using your DNS servers IP as the primary IP, my server's IP is 192.168.0.100 thus my resolv.conf looks like that with my IP at the first place:
domain tm.local nameserver 192.168.0.100 nameserver 192.168.0.2 |
Save and Exit.
Configure named to start automatically at the boot time.
Open the rc.conf file in /etc:
ee /etc/rc.conf
We will then add the following line to it:
named_enable="YES" |
Save and Exit.
Start the named service:
/etc/rc.d/named start
You can try to dig for google.com to make sure all good with your DNS server:
dig google.com
If you saw at the end (probably the 3rd line from down) something like this:
;; SERVER: 192.168.0.100#53(192.168.0.100)
So this means your DNS server (e.g. 192.168.0.100) was the one who answered the query.
You can try then to ping your A records if all give the expected reply then your DNS is working fine.
10 Sources and References
- Official FreeBSD Handbook
- Using the ports collection (FreeBSD Handbook)
- Search FreeBSD Ports Collection
- PortMaster
- BIND 9 Administrator Reference Manual
- RFC 1034 - Domain Names: Concepts and Facilities
- RFC 1035 - Domain Names: Implementation and Specification
- The FreeBSD DNS Handbook
- Building a Server with FREEBSD 7