How to Change Hostname in CentOS/RHEL/OEL



Step1) Open the file /etc/sysconfig/network in vi editor and modify HOSTNAME to FQDN (test1.abs.com)

[root@jagan1 oracle]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=test1.abs.com
[root@jagan1 oracle]#

Step2) Change the hostname in /etc/hosts file 
 
Example:
192.168.72.128 test1.abs.com test1

[root@jagan1 oracle]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.72.128 test1.abs.com test1
[root@jagan1 oracle]#

step3) Run Hostname

[root@jagan1 oracle]# hostname test1.abs.com

step4) Restart networking 
 
[root@jagan1 oracle]# /etc/init.d/network restart
Shutting down loopback interface:                          [  OK  ]
Bringing up loopback interface:                            [  OK  ]
Bringing up interface eth0:  Active connection state: activating
Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/2
state: activated
Connection activated                                                          [  OK  ]
[root@jagan1 oracle]#

          Restart VM 

Step5) Re-Login and verify

[root@test1 ~]# hostname -f
test1.abs.com
[root@test1 ~]#
[root@test1 ~]# dnsdomainname
abs.com
[root@test1 ~]#

Hostname changed and domain name is matching as per /etc/resolv.conf


Comments

Popular posts from this blog

How To Recover Custom Identity And Custom Trust Keystore Password

Cannot load /etc/httpd/modules/mod_wl_24.so into server: libopmnsecure.so: cannot open shared object file: No such file or directory

How To Install Oracle WebLogic Server 12.2.1.1.0 Using Silent Mode ?