RHCSA 8.2: Hostname resolution
The hostname, a name in /etc/hosts, and a DNS server and search domain
set the NetworkManager way.
Before you start
The lab gives this VM a spare network interface, eth1, cabled to a small
lab network, 192.168.50.0/24, with a profile called eth1 that gives it
the address 192.168.50.10/24 and no DNS settings. It comes back at every
boot. Your SSH connection doesn't use it: set DNS on the eth1 profile,
and leave the main interface's profile alone. A DNS server on eth1 ranks
below the main interface's (the lab sets that up in
/etc/NetworkManager/conf.d/), so name lookups keep working.
The lab notes your hostname and puts it back when you reset it.
Tasks
- Set the hostname to
server1.example.com, persistently. - Make the name
web1(andweb1.example.com) resolve to192.168.50.20on this system only, so thatgetent hosts web1prints192.168.50.20 web1.example.com web1. - Make the system use DNS server
192.168.50.1and search domainexample.com(on theeth1profile), so that afternmcli connection upand a reboot,/etc/resolv.confhasnameserver 192.168.50.1andsearch example.com.
Hints
hostnamectl set-hostname;hostname,hostname -s./etc/hosts: address, full name, then the short name.nmcli connection modify eth1 ipv4.dns ... ipv4.dns-search ..., thennmcli connection up eth1. Don't edit/etc/resolv.confby hand: NetworkManager rewrites it.