How to configure a DNS server on Ubuntu?

How to configure a DNS server on Ubuntu?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by thelma.stanton , a year ago


To configure a DNS server on Ubuntu, you can follow these steps:

  1. Update the Ubuntu system:sudo apt update sudo apt upgrade
  2. Install the DNS server software (Bind9) by running the following command:sudo apt install bind9
  3. Configure the DNS server by editing the "/etc/bind/named.conf.options" file. You can use any text editor to do this. For example:sudo nano /etc/bind/named.conf.options
  4. Add the following lines to the "named.conf.options" file to allow your DNS server to respond to queries from other computers:listen-on port 53 { any; }; allow-query { any; };
  5. Create a zone file for your domain by creating a new file in the "/etc/bind" directory. For example, if your domain is "", you can create a file called "/etc/bind/" with the following contents:; ; BIND data file for ; $TTL 604800 @ IN SOA ( 2022040401 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 604800 ) ; Default TTL ; @ IN NS @ IN A ns1 IN A This file specifies the DNS records for your domain. In this example, it defines an "A" record for the domain and an "A" record for the nameserver.
  6. Edit the "/etc/bind/named.conf.local" file and add the following lines to it:zone "" { type master; file "/etc/bind/"; }; This tells the DNS server to use the zone file you just created for the "" domain.
  7. Restart the Bind9 service:sudo systemctl restart bind9

Your DNS server should now be configured and running. You can test it by querying it from another computer using the "nslookup" command. For example:

nslookup <ip_address_of_dns_server>