RHCSA Rapid Track
In this exercise, you will manually configure the system’s static host name, /etc/hosts file, and DNS name resolver.
Outcomes
You should be able to set a customized host name and configure name resolution settings.
Log in as the student user on workstation using student as the password.
From workstation, run the lab net-hostnames start command.
The command runs a start script that determine if the host, servera, is reachable on the network.
[student@workstation ~]$lab net-hostnames start
Use the ssh command to log in to
serveraas thestudentuser. The systems are configured to use SSH keys for authentication, so a password is not required to log in toservera.[student@workstation ~]$ssh student@servera...output omitted...[student@servera ~]$View the current host name settings.
Display the current host name.
[student@servera ~]$hostnameservera.lab.example.comDisplay the host name status.
[student@servera ~]$hostnamectl statusStatic hostname: n/a Transient hostname: servera.lab.example.com Icon name: computer-vm Chassis: vm Machine ID: f874df04639f474cb0a9881041f4f7d4 Boot ID: 22ae5279f57049678eda547bdb39a19d Virtualization: kvm Operating System: Red Hat Enterprise Linux 8.2 (Ootpa) CPE OS Name: cpe:/o:redhat:enterprise_linux:8.2:GA Kernel: Linux 4.18.0-193.el8.x86_64 Architecture: x86-64Note the transient hostname obtained from DHCP or mDNS.
Set a static host name to match the current transient host name.
Change the host name and host name configuration file.
[student@servera ~]$sudo hostnamectl set-hostname \servera.lab.example.com[sudo] password for student:student[student@servera ~]$View the content of the
/etc/hostnamefile which provides the host name at network start.servera.lab.example.com
Display the host name status.
[student@servera ~]$hostnamectl statusStatic hostname: servera.lab.example.com Icon name: computer-vm Chassis: vm Machine ID: f874df04639f474cb0a9881041f4f7d4 Boot ID: 22ae5279f57049678eda547bdb39a19d Virtualization: kvm Operating System: Red Hat Enterprise Linux 8.2 (Ootpa) CPE OS Name: cpe:/o:redhat:enterprise_linux:8.2:GA Kernel: Linux 4.18.0-193.el8.x86_64 Architecture: x86-64Note that the transient hostname is not shown now that a static hostname has been configured.
Temporarily change the host name.
Change the host name.
[student@servera ~]$sudo hostname testnameDisplay the current host name.
[student@servera ~]$hostnametestnameView the content of the
/etc/hostnamefile which provides the host name at network start.servera.lab.example.com
Reboot the system.
[student@servera ~]$sudo systemctl rebootConnection to servera closed by remote host. Connection to servera closed.[student@workstation ~]$From
workstationlog in toserveraasstudentuser.[student@workstation ~]$ssh student@servera...output omitted...[student@servera ~]$Display the current host name.
[student@servera ~]$hostnameservera.lab.example.com
Add a local nickname for the classroom server.
Look up the IP address of the classroom.example.com.
[student@servera ~]$host classroom.example.comclassroom.example.com has address 172.25.254.254Modify
/etc/hostsso that the additional name ofclasscan be used to access the IP address 172.25.254.254.127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 172.25.254.254 classroom.example.com classroom class 172.25.254.254 content.example.com content ...content omitted...
Look up the IP address of
class.[student@servera ~]$host classHost class not found: 2(SERVFAIL)[student@servera ~]$getent hosts class172.25.254.254 classroom.example.com classPing
class.[student@servera ~]$ping -c3 classPING 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 msExit from
servera.[student@servera ~]$exitlogout Connection to servera closed.[student@workstation ~]$