You are on page 1of 12

Net Dev

Activity
Configure basic DNS server in Linux using CLI

Blacktown College
Information Technology
Document Information
Document Owner: WSI­14­45 File Location:
/home/sking1/Desktop/2009­
1/02_Classess/01_NetDev/Weeks_02­
09/Activities/Week_05/05­1_Activity­DNS.odt

Created: 11. Mar. 2008 @ 16:37 Modified: 12. Mar. 2009

Author: Stephen King Page Count: 12

Version:  1.12
Table of Contents
Document Information..............................................................................................2
Objective...............................................................................................................................................5
Pre-requisit...........................................................................................................................................5
Resources..............................................................................................................................................5
VM Information....................................................................................................................................6
Virtual Machine Settings.................................................................................................................6
Interface Configuration....................................................................................................................6
User Configuration..........................................................................................................................6
Services Configuration....................................................................................................................6
Activity Start........................................................................................................................................7
Step 1 – Creating zone files.............................................................................................................7
Step 2 – Creating zone lookup files.................................................................................................8
Step 3 – Checking the Resolver.....................................................................................................10
Step 4– Testing..............................................................................................................................10
Lets add a new resource record......................................................................................................11
Self-Paced...........................................................................................................................................12
Blacktown College ­ Information Technology
NetDev ­ Activity

Objective
To configure a basic DNS service using command line tools

Pre-requisit
You should have a basic knowledge of DNS

Resources
You will need the following:
● Copy of SLES10­Base Virtual Machine, Provided on DVD

Note: When starting your virtual machine you may get a dialog box asking you about 
the ID, please select the Keep option.
Students will log in using normal user and switch user to root when required.

© Stephen King (WSIT­Blacktown College). Verbatim copying and distribution of 5 of 12
this entire article is permitted in any medium.
Blacktown College ­ Information Technology
NetDev - Activity

VM Information
The virtual machine for this exercise has the following configuration:

Virtual Machine Settings


Memory: 512
CD­ROM: Auto
Ethernet: Host Only
USB Controller: Present
Vmware Tools: Installed

Interface Configuration
IP Address:  172.18.255.254
Netmask: 255.255.0.0
Host Name: svr1
Domain Name: sample.com
Name Server: 172.18.255.254
Default Gateway: 172.18.0.2

User Configuration
Two users have been created:
Username Password
root secret
student password

Services Configuration
<What services have been configured> Nil

© Stephen King (WSIT­Blacktown College). Verbatim copying and 6 of 12
distribution of this entire article is permitted in any medium.
Blacktown College - Information Technology
Configure basic DNS in Linux using CLI

Activity Start
Change the current NIC configuration to:
IP Address = 192.168.0.254
Subnet Mask = 255.255.255.0
You change this by editing the file (with joe):
/etc/sysconfig/network/ifcfg­eth­id­00:0c:29:c7:b0:dc
reload the network configuration using the following command:
rcnetwork reload
Now we can begin:

Step 1 – Creating Zone Files


For this basic setup, we will be configuring 2 zones:
● Forward zone – Domain name to IP
● Reverse zone – IP to domain name
Item/Description Command
Make a copy of named.conf cp /etc/named.conf /etc/named.conf.old
Open named.conf using joe.  joe /etc/named.conf

Adding forward zone zone “sample.com” IN {


type master;
Scroll or page down to the very 
file “master/sample.db”;
end of this file and typ in the 
allow-update { none; };
information shown. };

Adding reverse zone Zone “0.168.192.in-addr.arpa” IN {


type master;
Once the forward zone has been 
file “master/0.168.192.db”;
added, we can add the reverse 
allow-update { none; };
zone beneath the forward zone };

Save the file and exit from joe CTRL + K+X

7 of 12 05-1_Activity-DNS
Blacktown College ­ Information Technology
NetDev - Activity

Step 2 – Creating Zone Lookup Files


The lines beginning with file “master/sample.db” and file “master/0.168.192.db”; in the 
zone sections we added to named.conf inform the system where to look in /var/lib/named/ 
for the zone lookup files.

Item/Description Command
Navigate to /var/lib/named cd /var/lib/named

We are going to copy  cp /var/lib/named/localhost.zone /var/lib/


localhost.zone to  named/master/sample.db
/var/lib/named/master/sample.
db . We will use this file as a 
template. Note, this command 
is  all on one line with a space 
between zone and /var.

Use joe to open sample.db joe /var/lib/named/master/sample.db

You should see a file similar to  $TTL 1W @ IN SOA @   root (


that shown  42 ; serial (d. adams)
2D ; refresh
4H ; retry
6W ; expiry
1W ) ; minimum

IN NS @
IN A 127.0.0.1
We will now modify this file to  $TTL 1W
suite our requirements. The  @ IN SOA svr1.sample.com.   root.sample.com.(
Bolded sections are the changes  42 ; serial (d. adams)
to be made. 2D ; refresh
4H ; retry
6W ; expiry
1W ) ; minimum

IN NS svr1.sample.com.

svr1 IN A 192.168.0.254

© Stephen King (WSIT­Blacktown College). Verbatim copying and 8 of 12
distribution of this entire article is permitted in any medium.
Blacktown College - Information Technology
Configure basic DNS in Linux using CLI

Item/Description Command
Save this file as sample.db CTRL + K +D
(Press enter to accept the file name that you have provided.)
With the file still open, modify  $TTL 1W
it for our reverse zone lookup  @ IN SOA svr1.sample.com.   root.sample.com.(
file 42 ; serial (d. adams)
2D ; refresh
4H ; retry
6W ; expiry
1W ) ; minimum

IN NS svr1.sample.com.

254 IN PTR svr1.sample.com.

Save the file as 0.168.192.db CTRL + K +D
Enter the filename 0.168.192.db
Press enter to accept the value you have entered.

Now close the file using CTRL  CTRL + C
+C. We do not want to save this  No, we do not want to save this file
file as doing so will overwrite a 
previous file

9 of 12 05-1_Activity-DNS
Blacktown College ­ Information Technology
NetDev - Activity

Step 3 – Checking The Resolver


Item/Description Command
Ensure that the file  cat /etc/resolv.conf
/etc/resolv.conf has the 
nameserver directive included

If you do NOT see the line name  echo “nameserver 192.168.0.254”>/etc/resolv.conf


server 192.168.0.254 in the 
output of cat, you will need to add 
it

Step 4– Testing

Item/Description Command
Check to see if the named  rcnamed status
service is running:
If it is stopped you will need to  rcnamed start
start it
We will use the nslookup  nslookup 192.168.0.254
command to ensure our DNS 
server is working
Then we will check the forward  nslookup svr1.sample.com
lookup
If your lookup does not return 
the correct result, check your 
configuration files and make any 
changes required.
After making changes you will  rcnamed reload
need to reload the configuration 
files. This is done using the 
following command:

© Stephen King (WSIT­Blacktown College). Verbatim copying and 10 of 12
distribution of this entire article is permitted in any medium.
Blacktown College - Information Technology
Configure basic DNS in Linux using CLI

Lets Add A New Resource Record


Now that we have a basic DNS system operating, lets add a resource record for a web server 
that will be operating on the same physical computer as our DNS. To do this we add the 
CNAME resource record type to our forward zone lookup file sample.db. 

Item/Description Command
open  joe /var/lib/named/master/sample.db
/var/lib/named/master/sample.db

Add the bolded line to the end of the  $TTL 1W
file @ IN SOA svr1.sample.com.   root.sample.com.(
42 ; serial (d. adams)
2D ; refresh
4H ; retry
6W ; expiry
1W ) ; minimum

IN NS svr1.sample.com.

svr1 IN A 192.168.0.254
www CNAME svr1

Use CTRL + K + X to save and exit ctrl + X

Use the following command to  rcnamed reload


reload the DNS files

Use nslookup to check that  nslookup www.sample.com


www.sample.com can be resolved

END OF ACTIVITY

11 of 12 05-1_Activity-DNS
Blacktown College ­ Information Technology
NetDev - Activity

Self-Paced
Now that you have set­up DNS within the context given, try to make changes such as:

● Change NIC settings using different subnets
● Redo DNS (named.conf etc) for these new settings
● Add extra zones:
○ techsupport.sample.com
○ catalog.sample.com

© Stephen King (WSIT­Blacktown College). Verbatim copying and 12 of 12
distribution of this entire article is permitted in any medium.

You might also like