hosts.txt file on a central server (WHOIS directory)Before you continue with this topic, please make sure that you understand the following terminology.
lamp.computerstudi.es. (notice the . at the end).com, .net, .org, .ca, .es, etc.device.department.country.company.tld., and mail1.student.georgianc.on.ca.dnsmasq, Microsoft DNS, Cisco Network Registrar (CNR), NSD, Unbound, etc. For more information, see: https://en.wikipedia.org/wiki/Comparison_of_DNS_server_softwareFor more detailed information, see DNS root zone article on Wikipedia.
The global DNS root servers were previously overseen by ICANN (Internet Corporation for Assigned Names and Numbers) and by the National Telecommunications and Information Administration (NTIA), an agency of the United States Department of Commerce.
As of Oct 1, 2016, ICANN has delegated the duties to IANA (Internet Assigned Numbers Authority), which has outsourced the distribution services to Verisign (a US-based corporation).
Due to limitations of the UDP protocol, there are only 13 global root servers from a to m.
a.root-servers.net to m.root-servers.neta and j servers are operated by VerisignFor the sake of redundancy and load balancing, each root server is a cluster of many servers that respond to anycast requests. (See https://root-servers.org/)
When configuring a DNS server for the first time, the IP address of at least one root server is needed to retrieve the current list of all other name servers.
whois information)Resolver is a client software in an end device that "resolves" DNS names to IP addresses. A resolver software is usually included with or is built into an OS or network device software/firmware. DNS names are largely for humans, and machines using TCP/IP do not understand them. Any network-connected device using TCP/IP protocol must transmit network packets by including a destination IP address in the IP headers. The resolver software uses the DNS protocol to contact upstream DNS servers to obtain IP addresses for any DNS name before your system is able to assemble and transmit network packets to that destination.
Ubuntu uses systemd.resolved (8) as its resolver. Here are some relevant files and configurations:
/etc/hosts file is the static lookup table (see https://en.wikipedia.org/wiki/Hosts_(file) )/etc/resolve.conf is the resolver configuration fileresolvectl utility to view details about the current resolver status and upstream servers being used. Try the resolvectl status command on your system to view the current status of the resolver./etc/nsswitch.conf (see man nsswitch.conf): "Name Service Switch configuration file, used by the GNU C Library and certain other applications to determine the sources from which to obtain name-service information in a range of categories, and in what order".This is an example of a "recursive DNS query" where the DNS server communicates with several other DNS servers to find the IP address of a specific host before returning the IP to the requesting DNS client.
Example Address: fqdn.subdomain.domain.tld. (notice the . at the end!)
tld.) -> returns authoritative TLD (address of the NS to ask about domain.tld.)subdomain.domain.tld.)fqdn.subdomain.domain.tld.)
Ubuntu provides the dnsutils package containing several utilities useful for troubleshooting and NS lookup tasks. Some included utilities are:
nslookup (1): query Internet name servers interactivelydig (1) : DNS lookup utilityhost (1): DNS lookup utilitygetent (1): get entries from Name Service Switch librariesYou can ask a DNS server to find an IP address from a DNS name, or you can ask for a "reverse lookup" where you provide the IP address in order to find a FQDN. For a reverse lookup to be successful, the NS server must be configured with the appropriate PTR record entries in the zone file. For more information, see https://en.wikipedia.org/wiki/Reverse_DNS_lookup.
If you are interested in the history of BIND, then visit https://www.isc.org/bindhistory/.
BIND has been around since 1983 and is still in use extensively. If you are administering any websites or are in charge of managing domains, chances are your DNS service provider will require you to maintain and provide your domain name configuration in a format that aligns with the BIND zone file configuration.
BIND can act as a primary, secondary, forwarding, or caching DNS server.
Primary Server: Provides authoritative data for a domain
Secondary Server: Provides authoritative data for a domain, as long as it can stay up to date
Forwarding server: forwards DNS requests to another server
Caching servers: do a recursive search and save responses for quicker access
The main BIND configurations are located under /etc/bind. Here are some of the configuration files and their intended functions:
named.conf # configuration files for the bind daemonnamed.conf.local # local server configuration
type to primary (or master for older versions) in named.conf.localfile directiveallow-transfer keyword is specified, it can supply zone data to secondary serverstype to secondary (or slave in older versions) in named.conf.localprimary (or master) keyword to specify the primary servernamed.conf.options # daemon optionsnamed.conf.default-zones # provides zone data for RFC-defined zonesdb.root # provides DNS root server records
localhost # provides DNS data for the localhostIn Ubuntu, the BIND service is managed using systemd:
sudo service bind9 [ start | stop | restart | reload]rndc [ reload | stats | flush | status ]rndc can be less disruptive than restarting the entire daemon, especially on larger servers with many configurations.named-checkzone utility is used to verify the syntax of the zone files.
named-checkzone example.com /etc/bind/db.example.comnamed-checkconf <conffilename> is used to verify the syntax of configuration filesNote: The named-checkzone and named-checkconf utilities only check for syntax and cannot detect wrong or missing information!
BIND logs are sent to syslogs and are stored at /var/log/syslog. You can query or search syslogs for troubleshooting or monitoring BIND.
Even if you never set up your own DNS server, where you may need to create your own zone files for your domain, you will need to understand exactly what goes into a zone file in order to be able to configure any domain hosted at any provider. You will also need to know the meaning of these directives when using tools such as nslookup for troubleshooting or investigating a DNS name. The following are the important directives in the zone file:
IN: Internet Class RecordSOA: start of authorityNS: name serverMX: mail exchangerA: IPv4 address (32bits)AAAA: IPv6 address (128bits)CNAME: canonical name = AliasHere is an example of a zone file:
$ORIGIN example.com. ; designates the start of this zone file in the namespace
$TTL 3600 ; default expiration time (in seconds) of all RRs without their own TTL value
example.com. IN SOA ns.example.com. username.example.com. ( 2020091025 7200 3600 1209600 3600 )
; Legend for the above numbers:
; 2020091025 ; Serial number, increment with every change
; 7200 ; Refresh
; 3600 ; Retry
; 1209600 ; Expire
; 3600 ; Negative Cache TTL
;
example.com. IN NS ns ; ns.example.com is a nameserver for example.com
example.com. IN NS ns.somewhere.example. ; ns.somewhere.example is a backup nameserver for example.com
example.com. IN MX 10 mail.example.com. ; mail.example.com is the mailserver for example.com
@ IN MX 20 mail2.example.com. ; equivalent to the above line, "@" represents the zone origin
@ IN MX 50 mail3 ; equivalent to the above line, but using a relative host name
example.com. IN A 192.0.2.1 ; IPv4 address for example.com
IN AAAA 2001:db8:10::1 ; IPv6 address for example.com
ns IN A 192.0.2.2 ; IPv4 address for ns.example.com
IN AAAA 2001:db8:10::2 ; IPv6 address for ns.example.com
www IN CNAME example.com. ; www.example.com is an alias for example.com
wwwtest IN CNAME www ; wwwtest.example.com is another alias for www.example.com
mail IN A 192.0.2.3 ; IPv4 address for mail.example.com
mail2 IN A 192.0.2.4 ; IPv4 address for mail2.example.com
mail3 IN A 192.0.2.5 ; IPv4 address for mail3.example.com$ORIGIN example.com. ; designates the start of this zone file in the namespace
$TTL 3600 ; default expiration time (in seconds) of all RRs without their own TTL value
example.com. IN SOA ns.example.com. username.example.com. ( 2020091025 7200 3600 1209600 3600 )
; Legend for the above numbers:
; 2020091025 ; Serial number, increment with every change
; 7200 ; Refresh
; 3600 ; Retry
; 1209600 ; Expire
; 3600 ; Negative Cache TTL
;
example.com. IN NS ns ; ns.example.com is a nameserver for example.com
example.com. IN NS ns.somewhere.example. ; ns.somewhere.example is a backup nameserver for example.com
example.com. IN MX 10 mail.example.com. ; mail.example.com is the mailserver for example.com
@ IN MX 20 mail2.example.com. ; equivalent to the above line, "@" represents the zone origin
@ IN MX 50 mail3 ; equivalent to the above line, but using a relative host name
example.com. IN A 192.0.2.1 ; IPv4 address for example.com
IN AAAA 2001:db8:10::1 ; IPv6 address for example.com
ns IN A 192.0.2.2 ; IPv4 address for ns.example.com
IN AAAA 2001:db8:10::2 ; IPv6 address for ns.example.com
www IN CNAME example.com. ; www.example.com is an alias for example.com
wwwtest IN CNAME www ; wwwtest.example.com is another alias for www.example.com
mail IN A 192.0.2.3 ; IPv4 address for mail.example.com
mail2 IN A 192.0.2.4 ; IPv4 address for mail2.example.com
mail3 IN A 192.0.2.5 ; IPv4 address for mail3.example.comnslookupdighostgetentservice bind9 <start | stop | restart | reload>rndc <reload | stats | flush | status>name-checkzone <zone> <zonefile>named-checkconf <conffilename>/etc/hosts/etc/resolv.conf/etc/nsswitch.conf/etc/bind
named.conf.localnamed.conf.optionsnamed.conf.default-zonesdb.rootlocalhost