Home
Configuring HostName
Configuring HostName
- There are three classes of hostname: static, pretty and transient
· The “ static” host name is the traditional hostname, which can be chosen by the user, and is stored in the /etc/hostname file.
· The “ transient” hostname is a dynamic hostname maintained by the kernel. It is initialized to the static host name by default, whose value defaults to “ localhost” . It can be changed by DHCP or mDNS at runtime.
· The “pretty” hostname is a free-form UTF8 host name for presentation to the user.
- A host name can be a free-form string up to 64 characters in length. However, Red Hat recommends that both static and transient names match the fully-qualified domain name (FQDN) used for the machine in DNS, such as host.example.com.
- Use of hostnamectl tool to set hostname will enforce the following:
· Static and transient host names to consist of a-z, A-Z, 0 -9 , “ -” , “ _” and “ . ” only, to not begin or end in a dot, and to not have two dots immediately following each other.
· The size limit of 64 characters is enforced.
- Setting up hostname using nmtui
[root@localhost ~]# nmtui
[root@localhost ~]# bash[root@testvm07001 ~]#
- Files those are modified for the hostname changes are as shown below,
[root@localhost NetworkManager]# cat /etc/NetworkManager/NetworkManager.conf[main]plugins=ifcfg-rh[keyfile]hostname=testvm07001[root@localhost NetworkManager]# cat /etc/hostnametestvm07001
- Setting up hostname using hostnamctl command, First we will check  the hostname status
[root@testvm07001 ~]# hostnamectl status   Static hostname: testvm07001         Icon name: computer           Chassis: n/a        Machine ID: 0de148c5fca94a1b9d027a1c6f7c9dd4           Boot ID: 3dcf2a0d34d3423484177c5ba6a7ee20    Virtualization: oracle  Operating System: CentOS Linux 7 (Core)       CPE OS Name: cpe:/o:centos:centos:7            Kernel: Linux 3.10.0-123.9.2.el7.x86_64      Architecture: x86_64
- Now we will set hostname and check for changes in respective files,
[root@testvm07001 ~]# hostnamectl set-hostname testvm07002[root@testvm07001 ~]# hostnamectl status   Static hostname: testvm07002         Icon name: computer           Chassis: n/a        Machine ID: 0de148c5fca94a1b9d027a1c6f7c9dd4           Boot ID: 3dcf2a0d34d3423484177c5ba6a7ee20    Virtualization: oracle  Operating System: CentOS Linux 7 (Core)       CPE OS Name: cpe:/o:centos:centos:7            Kernel: Linux 3.10.0-123.9.2.el7.x86_64      Architecture: x86_64[root@testvm07001 ~]# cat /etc/NetworkManager/NetworkManager.conf[main]plugins=ifcfg-rh[keyfile]hostname=testvm07001[root@testvm07001 ~]# cat /etc/hostnametestvm07002
- Setting up pretty hostname using hostnamctl command,
[root@testvm07001 ~]# hostnamectl set-hostname "Sandeep's VM" --pretty
- Setting up transient hostname using hostnamctl command,
[root@testvm07001 ~]# hostnamectl set-hostname "testvm07005" --transient[root@testvm07001 ~]# hostnamectl status   Static hostname: testvm07002   Pretty hostname: Sandeep's VMTransient hostname: testvm07005         Icon name: computer           Chassis: n/a        Machine ID: 0de148c5fca94a1b9d027a1c6f7c9dd4           Boot ID: 3dcf2a0d34d3423484177c5ba6a7ee20    Virtualization: oracle  Operating System: CentOS Linux 7 (Core)       CPE OS Name: cpe:/o:centos:centos:7            Kernel: Linux 3.10.0-123.9.2.el7.x86_64      Architecture: x86_64
- Setting up hostname using nmcli command and checking changes in the files,
[root@myserver ~]# nmcli general hostname myserver2[root@myserver ~]# cat /etc/hostnamemyserver2[root@myserver ~]# cat /etc/NetworkManager/NetworkManager.conf[main]plugins=ifcfg-rh[keyfile]hostname=myserver2


No comments:
Post a Comment