Today, hostname settings are not very concerned, but once a Linux host encounters a hostname setting problem, it may also cause some incredible network problems and service process problems.
Hostname check,
Uname-n
Hostname-A |-S |-d |-F
Hostname commands can be used to determine the host and hostname settings;
The gethostname () function gets localhost because hostname is not set.
Settings of/etc/hosts;
For DHCP hosts, the settings are as follows,
127.0.0.1myhost.mydomain.comlocalhost.localdomain localhost myhost
For hosts with fixed IP addresses,
127.0.0.1localhost.localdomain localhost
192.168.0.10myhost.mydomain.commyhost
Run/etc/init. d/network restart after setting. Otherwise, it will not work.
Use the hostname command to set the hostname,
Hostname myhost.mydomain.com
While/etc/hostname can exist and can be absent,
Check/etc/sysconfig/network. For hosts with fixed IP addresses,
Hostname = "myhost.mydomain.com"
Networking = Yes
For DHCP hosts, we recommend that you add settings to the interface settings of/etc/sysconfig/networking-scripts/. Generally, dhcp_hostname is used;
The most direct hostname is recorded in/proc/kernel/hostname.
Echo "myhost.mydomain.com">/proc/kernel/hostname
.
Let's talk about it first!