Skip to content

Linux Foundations / Follow traffic and find the fault ยท Step 29 of 46

Lesson: What is DNS?Switch
โ† Linux Foundations

Network operations

What is DNS?

Learn how the Domain Name System turns names into IP addresses and why Linux depends on it.

Computers reach each other by IP address, but people remember names. The Domain Name System (DNS) connects the two. You ask for example.com, and DNS answers with addresses your machine can send packets to.

Names instead of numbers

Without DNS you would have to memorise an address for every website and server, and update your notes whenever one moved. With DNS the name stays the same while the owner changes the address behind it.

On Linux you can ask the system to look up a name with getent:

$ getent ahostsv4 localhost
127.0.0.1       STREAM localhost
127.0.0.1       DGRAM
127.0.0.1       RAW

localhost is answered locally, but a public name such as example.com normally needs a DNS server.

A distributed database

No single server holds every name. DNS is a distributed, hierarchical database. Names are read from right to left, from general to specific:

www.example.com.

The final dot is the root, usually left off when typing. com is a top-level domain, example is a domain registered under it, and www is a name inside that domain. Each level can hand responsibility for the level below to someone else. This is called delegation.

More than addresses

DNS stores typed records. An A record holds an IPv4 address and an AAAA record holds an IPv6 address. An MX record names the mail servers for a domain.

$ dig +short example.com MX
0 .

Your results for other domains will differ. The answer above is a "null MX", which says the domain accepts no mail.

Where your machine asks

Your Linux system sends questions to a resolver, whose address is usually listed in /etc/resolv.conf:

$ cat /etc/resolv.conf
nameserver 192.168.1.1

You will often see 127.0.0.53 instead. That is the local stub of systemd-resolved, used by Ubuntu and some other distributions, which forwards your questions onward. Run resolvectl status there to see the real servers.

When DNS fails, the network can look broken even though it works: reaching an IP address succeeds while reaching a name fails.

The networking basics guide explains the addressing underneath.

Try it

  1. Run cat /etc/resolv.conf and note the nameserver lines.
  2. Run getent ahosts example.com and compare the addresses with a classmate or a second machine.
  3. If dig is installed, run dig +short example.com A. On Debian and Ubuntu it comes from dnsutils or bind9-dnsutils, on Fedora and RHEL from bind-utils.

Check your understanding

What is DNS?

All 4 sections ยท no timer

Unlimited retries

Questions from every section are combined into one assessment. Answer them all correctly to complete the article.

Your completion saves in this browser. Sign in to sync it to your account.