Diagnosing and Correcting Hostname Resolution Problems

Hostname resolution is based on the relationship between hostnames such as enterprise5a.example.org and IP addresses such as 192.168.44.66. First, the default hostname is defined in /etc/sysconfig/network, based on the HOSTNAME directive. Hostnames are associated with IP addresses in /etc/hosts. If you use a DNS service, you need to make sure that the DNS server's IP address is identified in /etc/resolv.conf. If you use DHCP to get your IP address, it overwrites the DNS server addresses /etc/ resolv.conf, unless PEERDNS=no before the BOOTPROTO=dhcp directive in /etc/ sysconfig/network-scripts/ifcfg-eth0. Then a command like dhclient eth0 will acquire the DNS server address(es) from the DHCP server and place them in /etc/resolv.conf.

When there's appropriate routing information, as shown by the route command, along with DNS information in /etc/resolv.conf, you can apply the ping command to confirm connectivity to the external host of your choice.

For this exercise, you'll need a partner. Have your partner make changes to your system. As your partner works to create a network problem for you to solve on your computer, look away until the computer is rebooting.

  1. Back up the configuration file associated with the DNS server, /etc/resolv .conf. Back up the /etc/hosts configuration file. Back up the /etc/host.conf configuration file. Make sure to back up these files to a non-standard location, in case your partner also backs up any files before changing them.

  2. Open the /etc/host.conf configuration file in a text editor. If it isn't already as shown, change the directive in this file to:

    order hosts,bind
  3. Open the /etc/hosts configuration file. Set the name of another computer on your network (which supports SSH access) to an incorrect IP address.

  4. Reboot your system, and let your partner back at the computer. Tell him or her to try connecting to another system on your network (the one you've set to the wrong IP address).

  5. Make sure to tell your partner to back up any files that he or she might change to the appropriate home directory.

  6. If your partner gives up, restore the original /etc/hosts configuration file (and anything else your partner might have changed).

    Image from book