How To easily Install and configure BIND on Ubuntu 16.04?

Saman Baboli
3 min readOct 18, 2018

--

BIND is open source software that enables you to publish your Domain Name System (DNS) information on the Internet, and to resolve DNS queries for your users. The name BIND stands for “Berkeley Internet Name Domain”, because the software originated in the early 1980s at the University of California at Berkeley.

In this guide, we’ll learn how to get BIND installed on your Ubuntu 16.04 server.

1 — How a DNS server works. 2 -How a web server works.

Step 1: Install BIND

This is our first interaction with the apt packaging system in this session, so we’ll update our local package index so that we have access to the most recent package listings.

$ sudo apt-get update

Now can install bind9:

$ sudo apt-get install bind9

If bind installed successfully you must see that message:

* Starting domain name service... bind9      [OK]

Step 2: Configure

Open named.conf.local :

$ nano /etc/bind/named.conf.local

And put following code in to it.

Notice that replace domain.com with your own domain name.

zone "domain.com" {
type master;
file "/etc/bind/zones/domain.com.db";
};

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

Run following commands :

$ cd /etc/bind
$ mkdir zones
$ cd zones
$ nano domain.com.db // replace domain.com with your domain name

And put following codes in to it

  • replace domain.com with your domain address.
  • replace zzz.zzz.zzz.zzz with your server IP
; BIND data file for domain.com
;
$TTL 14400
@ IN SOA ns1.domain.com. host.domain.com. (
201006601 ; Serial
7200 ; Refresh
120 ; Retry
2419200 ; Expire
604800) ; Default TTL
;
domain.com. IN NS ns1.domain.com.
domain.com. IN NS ns2.domain.com.

domain.com. IN MX 10 mail.domain.com.
domain.com. IN A zzz.zzz.zzz.zzz

ns1 IN A zzz.zzz.zzz.zzz
ns2 IN A zzz.zzz.zzz.zzz
www IN CNAME domain.com.
mail IN A zzz.zzz.zzz.zzz
ftp IN CNAME domain.com.
domain.com. IN TXT "v=spf1 ip4:zzz.zzz.zzz.zzz a mx ~all"
mail IN TXT "v=spf1 a -all"

Then run this command

$ nano /etc/bind/zones/rev.3.2.1.in-addr.arpa

And put these codes at the bottom of it

Notice that replace domain.com with your own domain name.

@ IN SOA domain.com. host.domain.com. (
2010081401;
28800;
604800;
604800;
86400 );

IN NS ns1.domain.com.
4 IN PTR domain.com.

open this file

nano /etc/resolv.conf

And put this on it

search domain.com

And at the end we should restart the bind with following command:

$ /etc/init.d/bind9 restart

With following command we can check service status to make sure the service is running

$ service bind9 status

Output:

● bind9.service - BIND Domain Name Server
Loaded: loaded (/lib/systemd/system/bind9.service; enabled; vendor preset: enabled)
Drop-In: /run/systemd/generator/bind9.service.d
└─50-insserv.conf-$named.conf
Active: active (running) since Thu 2018-09-20 23:12:14 +0430; 3 weeks 6 days ago
Docs: man:named(8)
Main PID: 18382 (named)
Tasks: 27
Memory: 9.0M
CPU: 8.529s
CGroup: /system.slice/bind9.service
└─18382 /usr/sbin/named -f -u bind

Well done, your DNS server is ready to use.

Next step:

To publish your website, you need a web server, so you can use a web server like NGINX to serve your content to world wide web.

for further information check NGINX official website.

--

--

Saman Baboli
Saman Baboli

Written by Saman Baboli

Software Developer 📍Amsterdam, Netherlands

Responses (2)