hostname cmd 與 kernel.hostname
hostname cmd 及 sysctl 的 kernel.hostname 會設置系統的 hosname
查看當前系統的 hostname:
cat /proc/sys/kernel/hostname
Or
hostname
設定 hostname
[A]
/etc/sysconfig/network
HOSTNAME=??????????
P.S.
要 service network restart 才套用
它會設定 $HOSTNAME
echo $HOSTNAME
[B]
修改 /etc/hostname
FQDN
determined by the resolver subsystem
查看
# IP (wan ip)---> hostname
hostname -f
domainname (hostname -d)
/etc/resolv.conf
domain localdomain
當 ping 一個 hostname 時, 比如 ServerA, 當找不到時, 它會自加上 ServerA.localdomain
# tell resolvconf to regenerate resolv.conf
resolvconf -u
NIS domain name(domainname)
Domainname will print the NIS domainname of the system (set, get)
* gethostname
FQDN(dnsdomainname)(hostname --fqdn )
# The FQDN of the system is the name that the resolver(3) returns for the host name.
# It is not possible to set the FQDN or the DNS domain name with the dnsdomain name command
resolver
* getaddrinfo
* gethostname
P.S.
this is effective only until the next reboot.
# only contain the hostname and not the FQDN
/etc/hostname
Centos7 set & view hostname
# view
hostnamectl status
# set
hostnamectl set-hostname xxx