Introduction
In this challenge, you will learn how to configure hostname resolution on a Linux system. Proper hostname resolution is essential for network communication. You will practice setting up static hostname resolution using the /etc/hosts file and then configure the system to use a DNS server for dynamic resolution.
Configure Static Hostname Resolution
Your first task is to configure static hostname resolution. This method is useful for small networks or for overriding public DNS entries. You will edit the /etc/hosts file to map an IP address to a hostname.
Tasks
- Configure static hostname resolution for
myhost.example.com.
Requirements
- Edit the
/etc/hostsfile to map the IP address192.168.1.100to the hostnamemyhost.example.com. - Verify that the hostname
myhost.example.comcorrectly resolves to192.168.1.100.
Hints
- Use a command-line text editor like
nanoorviwithsudoprivileges to edit/etc/hosts. - The
getent hosts <hostname>command is a reliable way to test name resolution.
Example
After correctly configuring the /etc/hosts file, the output of the getent command should be:
$ getent hosts myhost.example.com
192.168.1.100 myhost.example.com
Configure Dynamic Hostname Resolution
Now, you will switch from static to dynamic (DNS-based) resolution. For this exercise, a simple DNS server has been pre-configured and is running on your local machine (127.0.0.1). Your task is to disable the static entry and configure your system to use this DNS server.
Tasks
- Disable the static hostname entry from the previous step.
- Configure the system to use the local DNS server.
Requirements
- The static entry for
myhost.example.comin/etc/hostsmust be disabled. You can do this by deleting the line or commenting it out with a#at the beginning. - Configure the system's DNS client to use the nameserver at
127.0.0.1. - Verify the new configuration using the
digcommand.
Hints
- The primary file for configuring a DNS client is
/etc/resolv.conf. - The
digcommand is a powerful tool for querying DNS servers.
Example
After correctly configuring the resolver and disabling the static host entry, the dig command should produce output similar to this, showing the resolution from the server:
$ dig myhost.example.com
; <<>> DiG 9.16.23-RH <<>> myhost.example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 58851
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 0
;; QUESTION SECTION:
;myhost.example.com. IN A
;; AUTHORITY SECTION:
example.com. 5 IN SOA ns.icann.org. noc.dns.icann.org. 2025011748 7200 3600 1209600 3600
;; Query time: 62 msec
;; SERVER: 100.100.2.136#53(100.100.2.136)
;; WHEN: Fri Aug 15 17:18:27 CST 2025
;; MSG SIZE rcvd: 101
Summary
In this challenge, you learned how to manage basic hostname resolution. You practiced configuring static resolution by editing the /etc/hosts file and then switched to dynamic resolution by configuring the system as a DNS client via the /etc/resolv.conf file. These are fundamental skills for network configuration and system administration on Linux.



