Tag Archives: Network

Setting up a DNS for the local network on the Ubuntu Hardy Heron server

There is now an updated guide for Ubuntu 12.04: Setting up a DNS for the local network on the Ubuntu 12.04 (Precise Pangolin) server

Condensed version

This is my really condensed step by step procedure that I took to setup my local dns for our local network at home. It really isn’t more than just a shorter version of the great guides posted by Sam Davis:

BIND Caching Name Server Setup
BIND Master Server Setup

I really recommend that you read his two post to get some more information, then you can check my pointers and maybe my configurations posted below if you want yet another example to look at.

Step by step instructions

1: Make sure that the latest version of bind9 is installed (that’s the dns-server software):
sudo apt-get install bind9

2.1: Configure the DNS to cache requests:
sudo nano /etc/bind/named.conf.options

2.2: Uncomment or add the forwarders section and replace the x:es with the ip-address to the primary and secondary dns of your isp:

forwarders {
        x.x.x.x;
        x.x.x.x;
};

3.1: Make the server use its own DNS for lookups:
sudo nano /etc/resolv.conf

3.2: Change or add the nameserver directive to point to the local machine:
nameserver 127.0.0.1

3.3: You can also add a search directive, to that you don’t have to type the whole fully qualified domain name every time, just the computer name instead:
search home.lan

Note: This must also be done for other Ubuntu clients that use a static IP. But then it should point to the IP of the DNS server. If you have a DHCP server you should specify your DNS IP in its settings, as well as the search domain.

4.1: Define the zones for the local domain:
sudo nano /etc/bind/named.conf.local

4.2: Add a zone for the local domain:

zone "home.lan" IN {
    type master;
    file "/etc/bind/zones/home.lan.db";
};

4.3: Also add a zone for reverse dns lookups for the local network:

zone "10.10.10.in-addr.arpa" {
    type master;
    file "/etc/bind/zones/rev.10.10.10.in-addr.arpa";
};

Note: Make sure that it’s literal quotes that is used, so that they not are converted if you copy and past them to the terminal. You get literal quotes on a Swedish keyboard by pressing “Shif+2”, on an English keybord it might be “Shif+,” ?

5: Create the zones directory:
sudo mkdir /etc/bind/zones

6.1: Configure the local domain:
sudo nano /etc/bind/zones/home.lan.db

6.2: My settings, change to your match your host names and ip-addresses:

; Use semicolons to add comments.
; Do NOT add empty lines.
; Host-to-IP Address DNS Pointers for home.lan
; Note: The extra “.” at the end of addresses are important.
; The following parameters set when DNS records will expire, etc.
; Importantly, the serial number must always be iterated upward to prevent
; undesirable consequences. A good format to use is YYYYMMDDII where
; the II index is in case you make more that one change in the same day.
home.lan. IN SOA ubuntu.home.lan. hostmaster.home.lan. (
    2008080901 ; serial
    8H ; refresh
    4H ; retry
    4W ; expire
    1D ; minimum
)
; NS indicates that ubuntu is the name server on home.lan
; MX indicates that ubuntu is (also) the mail server on home.lan
home.lan. IN NS ubuntu.home.lan.
home.lan. IN MX 10 ubuntu.home.lan.
; Set the address for localhost.home.lan
localhost    IN A 127.0.0.1
; Set the hostnames in alphabetical order
print-srv    IN A 10.10.10.9
router       IN A 10.10.10.10
server       IN A 10.10.10.5
ubuntu       IN A 10.10.10.1
xbox         IN A 10.10.10.2

7.1: Create and edit the reverse lookup configuration file:
sudo nano /etc/bind/zones/rev.10.10.10.in-addr.arpa

7.2: My settings, reversed of the above:

; IP Address-to-Host DNS Pointers for the 10.10.10.0 subnet
@ IN SOA ubuntu.home.lan. hostmaster.home.lan. (
    2008080901 ; serial
    8H ; refresh
    4H ; retry
    4W ; expire
    1D ; minimum
)
; define the authoritative name server
           IN NS ubuntu.home.lan.
; our hosts, in numeric order
1         IN PTR ubuntu.home.lan.
2         IN PTR xbox.home.lan.
5         IN PTR server.home.lan.
9         IN PTR print-srv.home.lan.
10        IN PTR router.home.lan.

8: Restart bind to use the new settings:
sudo /etc/init.d/bind9 restart

9: Test that the dns lookups works with the local server:
host ping.sunet.se

The response should be:
ping.sunet.se has address 192.36.125.18
ping.sunet.se has IPv6 address 2001:6b0:7::18

10: Test that all of your computers are listed with the following command:
host -l home.lan

The output should list all of your entered hosts:

home.lan name server ubuntu.home.lan.
localhost.home.lan has address 127.0.0.1
print-srv.home.lan has address 10.10.10.9
router.home.lan has address 10.10.10.10
server.home.lan has address 10.10.10.5
ubuntu.home.lan has address 10.10.10.1
xbox.home.lan has address 10.10.10.2

11: Test that the reverse lookup works:

 host 10.10.10.1

Response:
1.10.10.10.in-addr.arpa domain name pointer ubuntu.home.lan.

Final words
Do not forget to update the serial every time you make any changes to a zone file.

Referenses:
BIND Caching Name Server Setup
BIND Master Server Setup

Change to static ip on the Ubuntu Hardy Heron server

There is now an updated guide for Ubuntu 12.04: Change to static ip on the Ubuntu 12.04 (Precise Pangolin) server

1.1: Edit /etc/network/interfaces:
sudo nano /etc/network/interfaces

1.2: Change from dhcp to static:

- iface eth0 inet dhcp
+ iface eth0 inet static
+        address 10.10.10.1
+        netmask 255.255.255.0
+        gateway 10.10.10.10
+        network 10.10.10.0
+        broadcast 10.10.10.255

2: Make sure that the name server is specified in ‘/etc/resolv.conf’:
nameserver 10.10.10.10

3: Uninstall the dhcp-client (otherwise it will overwrite your changes on the next renew cycle!):
sudo apt-get remove dhcp3-client

4: Restart the network to use the new settings:
sudo /etc/init.d/networking restart

Done 🙂