Bookmark this page

Guided Exercise: Configuring Host Names and Name Resolution

In this lab, you will configure the system host name and name resolution.

Outcomes

Customized host name and name resolution settings.

Reset your serverX system.

  1. View the current host name settings.

    1. Display the current host name.

      [student@serverX ~]$ hostname
      serverX.example.com
      
    2. Display the host name status.

      [student@serverX ~]$ hostnamectl status
         Static hostname: n/a
      Transient hostname: serverX.example.com
               Icon name: computer
                 Chassis: n/a
              Machine ID: 9f6fb63045a845d79e5e870b914c61c9
                 Boot ID: d4ec3a2e8d3c48749aa82738c0ea946a
        Operating System: Red Hat Enterprise Linux Server 7.0 (Maipo)
             CPE OS Name: cpe:/o:redhat:enterprise_linux:7.0:GA:server
                  Kernel: Linux 3.10.0-97.el7.x86_64
            Architecture: x86_64
      
  2. Set a static host name to match the current transient host name.

    1. Change the host name and host name configuration file. Replace the X with your station number and match the output of the previous step.

      [student@serverX ~]$ sudo hostnamectl set-hostname serverX.example.com
      
    2. View the configuration file providing the host name at network start.

      [student@serverX ~]$ cat /etc/hostname
      serverX.example.com
      
    3. Display the host name status.

      [student@serverX ~]$ hostnamectl status
         Static hostname: serverX.example.com
               Icon name: computer
                 Chassis: n/a
              Machine ID: 9f6fb63045a845d79e5e870b914c61c9
                 Boot ID: d4ec3a2e8d3c48749aa82738c0ea946a
        Operating System: Red Hat Enterprise Linux Server 7.0 (Maipo)
             CPE OS Name: cpe:/o:redhat:enterprise_linux:7.0:GA:server
                  Kernel: Linux 3.10.0-97.el7.x86_64
            Architecture: x86_64
      
  3. Temporarily change the host name.

    1. Change the host name.

      [student@serverX ~]$ sudo hostname testname
      
    2. Display the current host name.

      [student@serverX ~]$ hostname
      testname
      
    3. View the configuration file providing the host name at network start.

      [student@serverX ~]$ cat /etc/hostname
      serverX.example.com
      
    4. Reboot the system.

      [student@serverX ~]$ reboot
      
    5. Display the current host name.

      [student@serverX ~]$ hostname
      serverX.example.com
      
  4. Add a local nickname for the classroom server.

    1. Look up the IP address of the classroom.example.com.

      [student@serverX ~]$ host classroom.example.com
      classroom.example.com has address 172.25.254.254
      
    2. Modify /etc/hosts so that the name class has the IP address 172.25.254.254 and can be used to communicate with classroom.example.com.

      [student@serverX ~]$ sudo vim /etc/hosts
      [student@serverX ~]$ cat /etc/hosts
      127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
      ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
      
      172.25.254.254 classroom.example.com class
      172.25.254.254 content.example.com
      
    3. Look up the IP address of the class.

      [student@serverX ~]$ host class
      Host class not found: 2(SERVFAIL)
      [student@serverX ~]$ getent hosts class
      172.25.254.254    classroom.example.com class
      
    4. Ping class.

      [student@serverX ~]$ ping -c3 class
      PING classroom.example.com (172.25.254.254) 56(84) bytes of data.
      64 bytes from classroom.example.com (172.25.254.254): icmp_seq=1 ttl=64 time=0.397 ms
      64 bytes from classroom.example.com (172.25.254.254): icmp_seq=2 ttl=64 time=0.447 ms
      64 bytes from classroom.example.com (172.25.254.254): icmp_seq=3 ttl=64 time=0.470 ms
      
      --- classroom.example.com ping statistics ---
      3 packets transmitted, 3 received, 0% packet loss, time 2000ms
      rtt min/avg/max/mdev = 0.397/0.438/0.470/0.030 ms
      
Revision: rh124-7-1b00421