centos7修改主机名
2014-12-17 14:57
323 查看
http://www.itzgeek.com/how-tos/linux/centos-how-tos/change-hostname-in-centos-7-rhel-7.html#axzz3M8Skjvq4
After installing
the CentOS 7 on my server, i tried to change host name by modifying the /etc/sysconfig/network; it did not take an effect of the modification. Even after multiple reboot of server, the host name remains localhost.localdomain. The procedure to change the
host name in CentOS 7 is now totally different from the previous version, this guide will help you to setup the host name on CentOS 7 / RHEL 7.
CentOS 7 supports three class of Host Names:
Static – The static host name is traditional host which can be chosen by the user and is stored in /etc/hostname file.
Transient – The transient host name is maintained by kernel and can be changed by DHCP and mDNS.
Pretty – It is a free form UTF -8 host name for the presentation to the user.
HostName can be,
64 character in a length
Recommend to have FQDN
Consists of a-z,A-Z, 0-9, “-”, “_” and “.” only
How to Change:
Before changing the host name, lets check the current host name.
1. nmtui tool:
NetworkManaget tool is used to set the static host name in /etc/hostname file.
![](http://cdn1.itzgeek.com/wp-content/uploads/2014/07/nmtui-Change-HostName-1.jpg)
nmtui -Select Set HostName
Set the host name.
![](http://cdn2.itzgeek.com/wp-content/uploads/2014/07/nmtui-Change-HostName-2.jpg)
nmtui – Change HostName 2
restart the hostnamed to force the hostnamectl to notice the change in static host name.
You can verify the change in host name.
2. hostnamectl:
hostnamectl is used to change the host name, with this tool we can change all the three class of host name; here we look only static host name.
Check the current host name.
Set the hostname.
Check the host name again (Close the session and open new session using putty or console)
If you use this command, you do not require to notify the change in host name. Close the current session and re launch the terminal.
3. nmcli tool:
It can be used to query and setup the static host name in /etc/hostname file.
Check the hostname.
Change the host name.
restart the hostnamed to force the hostnamectl to notice the change in static host name.
4. Edit /etc/hostname
This is the simple, but requires a reboot of server to take an effect.
Note: Use the hostnamectl to change the host name, which fair better than other commands and does not require to update the kernel about the change in host name.
Read more: http://www.itzgeek.com/how-tos/linux/centos-how-tos/change-hostname-in-centos-7-rhel-7.html#ixzz3M8TzE0lG
© 2014 ITzGeek. All rights reserved.
After installing
the CentOS 7 on my server, i tried to change host name by modifying the /etc/sysconfig/network; it did not take an effect of the modification. Even after multiple reboot of server, the host name remains localhost.localdomain. The procedure to change the
host name in CentOS 7 is now totally different from the previous version, this guide will help you to setup the host name on CentOS 7 / RHEL 7.
CentOS 7 supports three class of Host Names:
Static – The static host name is traditional host which can be chosen by the user and is stored in /etc/hostname file.
Transient – The transient host name is maintained by kernel and can be changed by DHCP and mDNS.
Pretty – It is a free form UTF -8 host name for the presentation to the user.
HostName can be,
64 character in a length
Recommend to have FQDN
Consists of a-z,A-Z, 0-9, “-”, “_” and “.” only
How to Change:
Before changing the host name, lets check the current host name.
[root@localhost ~]# hostname localhost.localdomain |
NetworkManaget tool is used to set the static host name in /etc/hostname file.
![](http://cdn1.itzgeek.com/wp-content/uploads/2014/07/nmtui-Change-HostName-1.jpg)
nmtui -Select Set HostName
Set the host name.
![](http://cdn2.itzgeek.com/wp-content/uploads/2014/07/nmtui-Change-HostName-2.jpg)
nmtui – Change HostName 2
restart the hostnamed to force the hostnamectl to notice the change in static host name.
[root@localhost ~]# systemctl restart systemd-hostnamed |
[root@server ~]# hostname server.itzgeek.com [root@server ~]# cat /etc/hostname server.itzgeek.com [root@server ~]# cat /etc/sysconfig/network # Created by anaconda HOSTNAME=server.itzgeek.com |
hostnamectl is used to change the host name, with this tool we can change all the three class of host name; here we look only static host name.
Check the current host name.
[root@server ~]# hostnamectl status |
Static hostname: server.itzgeek.com Icon name: computer-vm Chassis: vm Machine ID: 565ea8b749544aca9d5563308f9e4bc2 Boot ID: 5c979d9b5f754df8b75a4e3aeabf2bad Virtualization: vmware Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-123.el7.x86_64 Architecture: x86_64 |
[root@server ~]# hostnamectl set-hostname client.itzgeek.com |
[root@client ~]# hostnamectl status |
Static hostname: client.itzgeek.com Icon name: computer-vm Chassis: vm Machine ID: 565ea8b749544aca9d5563308f9e4bc2 Boot ID: 5c979d9b5f754df8b75a4e3aeabf2bad Virtualization: vmware Operating System: CentOS Linux 7 (Core) CPE OS Name: cpe:/o:centos:centos:7 Kernel: Linux 3.10.0-123.el7.x86_64 Architecture: x86_64 |
3. nmcli tool:
It can be used to query and setup the static host name in /etc/hostname file.
Check the hostname.
[root@client ~]# nmcli general hostname client.itzgeek.com |
[root@client ~]# nmcli general hostname server.itzgeek.com |
[root@client ~]# systemctl restart systemd-hostnamed |
This is the simple, but requires a reboot of server to take an effect.
Note: Use the hostnamectl to change the host name, which fair better than other commands and does not require to update the kernel about the change in host name.
Read more: http://www.itzgeek.com/how-tos/linux/centos-how-tos/change-hostname-in-centos-7-rhel-7.html#ixzz3M8TzE0lG
© 2014 ITzGeek. All rights reserved.
相关文章推荐
- centos7修改主机名
- linux:centos6、centos7中关于修改主机名与ip映射的操作
- Centos7修改主机名
- CentOS7 配置网卡 虚拟机挂载光盘 搭建本地yum源 修改主机名
- centos7修改主机名
- centos7 修改主机名的方法(在centos7有效)
- centos7修改主机名方法
- rhcsa学习杂记—centos7命令行配置网络连接以及修改主机名
- Centos7 永久修改主机名
- Centos7 修改主机名
- Centos7系统下修改主机名操作笔记
- centos7修改主机名hostname
- CentOS7修改主机名(hostname)
- CentOS7系统如何修改主机名
- centos7修改主机名
- CentOS7修改主机名
- centos6.5和centos7不同的修改主机名的方法
- CentOS7修改主机名
- CentOS7 修改主机名
- CentOS7 修改主机名 hostnamectl命令