Cara Setting Hostname di CentOS 7


Cara setting hostname berikut adalah menggunakan hostnamectl (yang direkomendasikan). Selengkapnya cara setting hostname di CentOS 7 dapat menggunakan salah satu opsi berikut:

  1. hostnamectl command : Control the system hostname. This is recommended method.
  2. nmtui command : Control the system hostname using text user interface (TUI).
  3. nmcli command : Control the system hostname using CLI part of NetworkManager.

Perlu juga diketahui tipe-tipe hostname sebagai berikut:

  1. Static host name assigned by sysadmin. For example, “server1”, “wwwbox2”, or “server42.cyberciti.biz”.
  2. Transient/dynamic host name assigned by DHCP or mDNS server at run time.
  3. 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 root@server-ip-here hostnamectl set-hostname server1
atau
# hostnamectl set-hostname server1 -H root@192.168.1.42

Terakhir, restart hostnamed service :

# systemctl restart systemd-hostnamed

Verifikasi perubahan :

# hostnamectl status

Semoga bermanfaat.

Sumber: www[.]cyberciti[.]biz/faq/rhel-redhat-centos-7-change-hostname-command/

Leave a comment

Your email address will not be published. Required fields are marked *