A computer hostname represents a unique name that gets assigned to a computer in a network in order to uniquely identify that computer in that specific network. The hostname is set at the time when the CentOS operating system is installed or if you are spinning up a virtual machine it is dynamically assigned to the instance at startup.
The hostname is used by many of the networking programs (such as sendmail, Apache servers) to identify the machine. By default, your server is started with the server’s given name as the hostname. Some software, such as cPanel, CWP requires a valid Fully Qualified Domain Name (FQDN) for the hostname.
Types of hostnames (The hostname can be configured as follows):
Static host name assigned by sysadmin. For example, “server1”, “wwwBot2”, or “host.datahead.biz”.
Transient/dynamic host name assigned by DHCP or mDNS server at run time.
Pretty host name assigned by sysadmin/end-users and it is a free-form UTF8 host name for presentation to the user. For example, “Rubel’s netbook”.
On a CentOS Linux 7 server you can use any one of the following tool to manage hostnames:
hostnamectl command : Control the system hostname. This is a recommended method.
nmtui command : Control the system hostname using text user interface (TUI).
nmcli command : Control the system hostname using CLI part of NetworkManager.
1.Show Present Hostname :
The hostname is used by many of the networking programs (such as sendmail, Apache servers) to identify the machine. By default, your server is started with the server’s given name as the hostname. Some software, such as cPanel, CWP requires a valid Fully Qualified Domain Name (FQDN) for the hostname.
Types of hostnames (The hostname can be configured as follows):
Static host name assigned by sysadmin. For example, “server1”, “wwwBot2”, or “host.datahead.biz”.
Transient/dynamic host name assigned by DHCP or mDNS server at run time.
Pretty host name assigned by sysadmin/end-users and it is a free-form UTF8 host name for presentation to the user. For example, “Rubel’s netbook”.
On a CentOS Linux 7 server you can use any one of the following tool to manage hostnames:
hostnamectl command : Control the system hostname. This is a recommended method.
nmtui command : Control the system hostname using text user interface (TUI).
nmcli command : Control the system hostname using CLI part of NetworkManager.
1.Show Present Hostname :
# hostnamectl
# hostnamectl status
# hostname
# cat /etc/hostname
2.Change Hostname Temporary :# hostname host.datahead.biz
3.Change Hostname Permanently:# hostnamectl set-hostname host.datahead.biz
# hostnamectl
Static hostname: host.datahead.biz
Icon name: computer-vm
Chassis: vm
Machine ID: 7400071490ea4f7d931374824ad4b52c
Boot ID: 6e1f2d76495d4b318c25c4a1195aa130
Virtualization: vmware
Operating System: CentOS Linux 7 (Core)
CPE OS Name: cpe:/o:centos:centos:7
Kernel: Linux 3.10.0-862.14.4.el7.x86_64
Architecture: x86-64
It also writes this information to the /etc/hostname file as well. # cat /etc/hostname
host.datahead.biz
# vi /etc/hostname (To Edit)
host.datahead.biz
:x (save & quit)
4.One thing the hostnamectl command doesn’t do is modify the /etc/hosts file, so we’ll still need to do that# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
SERVER_IP host.datahead.biz host
:x (save & quit)
# vi /etc/sysconfig/network
# Created by anaconda
HOSTNAME=host.datahead.biz
:x (save & quit)
# vi /etc/resolv.conf
# Generated by NetworkManager
search datahead.biz
nameserver 8.8.4.4
nameserver 8.8.8.8
:x (save & quit)
5.Restart The services# systemctl status systemd-hostnamed
# systemctl enable network.service
# systemctl restart network.service
In EFA: no need to modify /etc/resolv.conf file, EFA will modify as below after EFA installation
# cat /etc/resolv.conf
nameserver 127.0.0.1
nameserver ::1
Comments
Post a Comment
You are always welcome to comment here, but your remarks should be relevant to the conversation. To keep the exchanges focused and engaging, we reserve the right to remove off-topic comments, or self-promoting URLs and vacuous messages.
We will try to reply to your queries as soon as time allows.
Regards,
Admin