DNS root record hardcoded then why it has ttl?

Typically you would explicitly configure the DNS root servers similar to the snippet below:

zone "." {
  type hint;
  file "/etc/bind/db.root";
};

Where you observe that zone type is not the common master nor slave but a special zone type called hint.

When the name server starts up, it only uses the root hints to find a responding root name server and will then get the current list of root name servers from there. Those are the root servers that will be actually be used during operation.

Since those are cached they will need a TTL and as you have observed: that TTL will decrease like any other cached DNS record.

If no hint zone is specified for class IN, the server uses a compiled-in default set of root servers hints. Source: the Bind Administrator Reference Manual.

As Brian explained in his answer the root zone does change, and as long as at least one name server remains valid the hint zone allows for such changes in the root name servers without requiring all existing name servers to update their static configuration files.


They aren't hard coded permanently - the root zone file does change over time so entries passed on to resolvers can't be set to last forever.

For example the current one was last updated in 2014 as show by the start of the file here:

;       This file holds the information on root name servers needed to
;       initialize cache of Internet domain name servers
;       (e.g. reference this file in the "cache  .  <file>"
;       configuration file of BIND domain name servers).
;
;       This file is made available by InterNIC 
;       under anonymous FTP as
;           file                /domain/named.cache
;           on server           FTP.INTERNIC.NET
;       -OR-                    RS.INTERNIC.NET
;
;       last update:    November 05, 2014
;       related version of root zone:   2014110501
;
; formerly NS.INTERNIC.NET
;
.                        3600000      NS    A.ROOT-SERVERS.NET.
A.ROOT-SERVERS.NET.      3600000      A     198.41.0.4
A.ROOT-SERVERS.NET.      3600000      AAAA  2001:503:ba3e::2:30

db.root is only used as part of the DNS server startup process to find the real current root servers. These are then updated as per the TTL.