What Is DNS? A Beginner's Guide to Domain Name Resolution on Linux
Learn what DNS is, how hostname-to-IP resolution works, and how DNS fits into Linux networking, DHCP, and troubleshooting.
DNS stands for Domain Name System. It is the naming and lookup system that translates human-readable hostnames and domain names into numeric IP addresses. This process is called name resolution.
DNS is a network service and protocol. It helps a computer discover the network address of a resource, such as a website, internal server, or other network service. After the address is found, the client uses normal network communication to connect to that address.
Why DNS Is Useful
Computers use IP addresses to identify network destinations. An IPv4 address is a numeric address such as 192.0.2.25. Numeric addresses work well for computers, but they are harder for people to remember and use than names such as fileserver or example.test.
DNS lets people use memorable names while allowing applications to obtain the numeric address needed for communication. For example, a browser can request the address for a website hostname before connecting to the website.
DNS is not the transport mechanism that carries the website's data. If you already know the destination IP address, a client can attempt to connect directly to that address without first using DNS. DNS simply makes it easier to locate and use network resources.
Hostnames, Domain Names, and IP Addresses
Hostname
A hostname is a name assigned to a host, such as a computer, server, or network device. An internal server might have the hostname home_server or fileserver.
Domain name
A domain name is a human-readable Internet name used to identify a site or service. A name such as www.example.test can identify a service that users want to reach.
IP address
An IP address is a numeric network address used to reach a host. IPv4 addresses use four numbers separated by periods, such as 203.0.113.10. IPv6 addresses use a different hexadecimal format.
A DNS record creates a relationship between a name and an address. In a simple lookup, the client asks, “What IP address belongs to this hostname?” The answer is a hostname-to-IP mapping.
Mappings may be static or dynamic. A static mapping is maintained manually and changes only when an administrator edits it. A dynamic mapping can be updated automatically, for example when devices receive changing addresses in a managed network.
DNS Components
| Component | Role in the DNS process | Example |
|---|---|---|
| DNS client or resolver | Requests or performs a name lookup on behalf of an application. | A Linux host resolving fileserver. |
| DNS server | Receives DNS queries and returns answers using name-to-address records. | A DNS service provided by a local router, company network, or Internet provider. |
| Hostname or domain name | The human-readable name being requested. | home_server or www.example.test. |
| IP address | The numeric address returned for the requested name. | 192.0.2.25. |
| Destination server or service | The host that the client ultimately wants to contact. | An internal file server or web server. |
The term DNS client can refer to the requesting computer, an application component, or the client-side resolver software. The DNS resolver is the client-side component that performs or initiates DNS lookups.
How Basic DNS Resolution Works
Consider a user entering a website hostname in a web browser:
- The user enters a hostname, such as
www.example.test, into an application. - The application or operating system's DNS client checks whether it already has a usable answer. If it needs to ask a server, it sends a DNS query to the configured DNS server.
- The DNS server looks for the requested name in its records. Depending on the DNS environment, it may answer from its own records or obtain the information from another DNS service.
- The DNS server sends a DNS response or reply. The response commonly contains an IP address.
- The client uses the returned IP address to communicate with the destination service. The browser then performs the appropriate application-level connection.
| Step | Actor | Action | Result |
|---|---|---|---|
| 1 | User or application | Requests a hostname. | A name lookup is needed. |
| 2 | DNS client | Sends a DNS query to its configured DNS server. | The server receives the name-resolution request. |
| 3 | DNS server | Finds a hostname-to-IP mapping in its records or DNS information. | An answer is prepared. |
| 4 | DNS server | Sends a DNS response. | The client receives an IP address or an error. |
| 5 | Client | Contacts the destination using the returned IP address. | Network communication with the requested service can begin. |
Example: Using a website name
A user enters a familiar website hostname in a browser. The host sends a DNS query to its configured resolver. The resolver returns an IP address, and the browser uses that address to establish its connection.
Example: Resolving an internal server
Suppose a client needs to reach home_server, but it does not know the server's numeric address. The client asks its DNS server for the address associated with home_server. After receiving the answer, the client connects to the internal server using that IP address.
DNS Server Configuration
A DNS client must know which DNS server to query. Therefore, DNS resolution depends on having at least one usable DNS server address configured for the client. A Linux system may receive this information from a network manager, a manually configured network setting, or another local service.
In many networks, DHCP, the Dynamic Host Configuration Protocol, automatically provides several network settings. These can include an IP address, a network route, and one or more DNS server addresses. DHCP supplies configuration information; DNS performs the later name-resolution work.
If no usable DNS server is configured, a client may still communicate with a destination when its IP address is known, but hostname-based connections can fail.
DNS in Linux Networking
DNS is one part of a Linux host's network configuration. It should be distinguished from interface addressing and basic connectivity:
| Concept | Primary purpose | Relationship to DNS |
|---|---|---|
| IP addressing | Gives a network interface a numeric address. | DNS can return an IP address, but it does not assign the client's interface address. |
| DNS | Resolves names into network addresses. | Provides the name-to-address lookup used before many hostname-based connections. |
| DHCP | Automatically delivers network configuration. | May provide DNS server addresses to the client. |
| Network interface configuration | Controls interface addresses, link state, and related connectivity settings. | Must provide working network connectivity before a remote DNS server can normally be queried. |
The modern Linux ip command is commonly used to inspect interfaces and addresses. For example:
ip addrifconfig is a legacy Linux and Unix command for viewing or configuring network interfaces. It is relevant to interface details, but it is not a primary DNS lookup tool. Current Linux environments generally prefer ip for interface inspection.
Changing an interface address does not automatically create or repair a hostname-to-IP record. Likewise, changing a DNS server setting does not assign an address to the local interface.
DNS Versus Direct IP Connections
There are two different steps that are easy to confuse:
- Resolution: converting a hostname into an IP address with DNS.
- Connection: using an IP address to communicate with a destination service.
If a user knows the correct IP address, the connection step may be attempted directly. Using a hostname is usually more practical because the name is easier to remember and the mapping can change without requiring every user to memorize a new number.
Basic DNS Troubleshooting
Hostname fails, but the IP address works
This symptom usually indicates a name-resolution problem rather than a basic IP-connectivity problem. Check the following:
- Confirm that the Linux client has a DNS server configured.
- Confirm that the configured DNS server is reachable over the network.
- Confirm that the requested hostname has a valid record on the appropriate DNS server.
Services work only with numeric IP addresses
If users can reach services by entering IP addresses but not by using names, review the client's DNS server settings. Check whether DHCP delivered valid DNS information and verify that the expected hostname-to-IP mapping exists on the DNS server.
An internal hostname does not resolve
An internal name may be missing from the DNS server's records, or the client may be querying the wrong DNS server. Verify the internal hostname record, confirm that the client uses the DNS server responsible for the internal network, and compare the expected address with the DNS answer.
Key Points
- DNS means Domain Name System.
- DNS performs name resolution by translating hostnames and domain names into IP addresses.
- A DNS client or resolver sends a query to a configured DNS server.
- The DNS server returns a response containing the requested address or an error.
- The client then uses the address to communicate with the destination service.
- DNS is separate from IP addressing, interface configuration, and the transport connection itself.
- DHCP may provide DNS server settings automatically, while DNS performs the lookup.
- When IP connections work but hostname connections fail, investigate DNS configuration and records.