
Cara setting hostname berikut adalah menggunakan hostnamectl (yang direkomendasikan). Selengkapnya cara setting hostname di CentOS 7 dapat menggunakan salah satu opsi berikut:
- hostnamectl command : Control the system hostname. This is recommended method.
- nmtui command : Control the system hostname using text user interface (TUI).
- nmcli command : Control the system hostname using CLI part of NetworkManager.
Perlu juga diketahui tipe-tipe hostname sebagai berikut:
- Static host name assigned by sysadmin. For example, “server1”, “wwwbox2”, or “server42.cyberciti.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, “Vivek’s netbook”.
Langkah-langkah setting hostname menggunakan hostnamectl. Melihat informasi hostname saat ini:
$ hostnamectl
## OR ##
$ hostnamectl status
Cara melakukan setting host name:
# hostnamectl set-hostname Your-New-Host-Name-Here
# hostnamectl set-hostname “Your New Host Name Here” –pretty
# hostnamectl set-hostname Your-New-Host-Name-Here –static
# hostnamectl set-hostname Your-New-Host-Name-Here –transient
Set host name ke “R2-D2” :
# hostnamectl set-hostname R2-D2
Set static host name ke “server1.cyberciti.biz” :
# hostnamectl set-hostname server1.cyberciti.biz –static
Set pretty host name to “Senator Padme Amidala’s Laptop” :
# hostnamectl set-hostname “Senator Padme Amidala’s Laptop” –pretty
Verify hasil setting baru :
# hostnamectl status
Cara delete host name :
# hostnamectl set-hostname “”
# hostnamectl set-hostname “” –static
# hostnamectl set-hostname “” –pretty
Cara ubah host name remotely :
# ssh [email protected] hostnamectl set-hostname server1
atau
# hostnamectl set-hostname server1 -H [email protected]
Terakhir, restart hostnamed service :
# systemctl restart systemd-hostnamed
Verifikasi perubahan :
# hostnamectl status
Semoga bermanfaat.
Sumber:
http[:]//www[.]cyberciti[.]biz/faq/rhel-redhat-centos-7-change-hostname-command/