Skip to content

Instantly share code, notes, and snippets.

@gilangvperdana
Last active December 30, 2022 17:58
Show Gist options
  • Save gilangvperdana/24081968f6bce720e52ff8e0acc0a433 to your computer and use it in GitHub Desktop.
Save gilangvperdana/24081968f6bce720e52ff8e0acc0a433 to your computer and use it in GitHub Desktop.
Create DNS Server with Bind9

Goals

Create an DNS server self-hosted on Virtual Machine Ubuntu Server with Bind9

Scenario

  • Make 192.168.1.10 as resolver if user access testing.gbesar.com
  • User change resolver on /etc/resolv.conf to ip BIND9 Virtual Machine

Preparing

Install bind9

apt install -y bind9

Create Zone

nano /etc/bind/named.conf.local
zone "testing.gbesar.com" {
 type master;
 file "/etc/bind/testing.gbesar.com";
};

Create Record

nano /etc/bind/testing.gbesar.com
$TTL    86400
@       IN      SOA     testing.gbesar.com. www.testing.gbesar.com. (
 2020071601      ;Serial
 3600            ;Refresh
 1800            ;Retry
 604800          ;Expire
 86400           ;Minimum TTL
)
@               IN      NS      ns1.testing.gbesar.com.
@               IN      NS      ns2.testing.gbesar.com.
@               IN      A       192.168.1.10
ns1             IN      A       192.168.1.10
ns2             IN      A       192.168.1.10
www             IN      CNAME   testing.gbesar.com.

Verify & Apply

named-checkzone testing.gbesar.com /etc/bind/testing.gbesar.com
systemctl restart bind9

Change Resolver on Client POV

## Linux
nano /etc/resolv.conf
nameserver YOUR_BIND9_VP_IP
ping testing.gbesar.com

Add

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment