Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save viktordw/ef766d8a5ce36a4dad61d779643ea6a6 to your computer and use it in GitHub Desktop.
Save viktordw/ef766d8a5ce36a4dad61d779643ea6a6 to your computer and use it in GitHub Desktop.
Create your own DNS server with bind9

Bind9 Basic Domain Configuration

Example Domain: mydomain.com

Install Bind9

foo@bar:~$ apt-get install bind9
foo@bar:~$ cd /etc/bind

Create Zone

Open file named.conf.local

foo@bar:/etc/bind$ nano named.conf.local

Add lines

zone "mydomain.com" IN {
  type master;
  file "/etc/bind/zones/mydomain.com.zone";
};

Zone file

Create folder and copy the example file

foo@bar:/etc/bind$ mkdir zones
foo@bar:/etc/bind$ cp db.local zones/mydomain.com.zone

Open your new file and replace localhost

foo@bar:/etc/bind$ nano zones/mydomain.com.zone
;
; BIND data file for local loopback interface
;
$TTL    604800
@       IN      SOA     mydomain.com. root.mydomain.com. (
                              2         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      mydomain.com.
@       IN      A       127.0.0.1
@       IN      AAAA    ::1

Restart bind9

foo@bar:/etc/bind$ service bind9 restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment