Permanently change the host name of an Oracle Cloud Infrastructure (OCI) compute instance
1: Edit /etc/sysconfig/network
change the parameter value for "hostname"
example:
# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=instance-ol6 <--------- change here
example:
# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=instance-ol6 <--------- change here
2: In the file /etc/oci-hostname.conf change the value of PRESERVE_HOSTINFO to 2.
/etc/oci-hostname.conf
PRESERVE_HOSTINFO=2
PRESERVE_HOSTINFO=2
This change will be persistent across reboots
For Oracle Linux 7
1: Update the /etc/hostname file with below command.
hostnamectl set-hostname <new name>
2: Edit the oci configuration file for hostnames as given below to update the needed value to 2.
vi /etc/oci-hostname.conf
PRESERVE_HOSTINFO=2
save the changes.
vi /etc/oci-hostname.conf
PRESERVE_HOSTINFO=2
save the changes.
3: Edit the FQDN from OCI console GUI
go to compute instances
--> select the instance
--> scroll down
--> at the left bottom corner select attached VNIC under resources
--> edit appropriate VNIC
--> change hostname to update FQDN
--> update VNIC
go to compute instances
--> select the instance
--> scroll down
--> at the left bottom corner select attached VNIC under resources
--> edit appropriate VNIC
--> change hostname to update FQDN
--> update VNIC
4: Reboot the instance
5: Check the hostname with hostname command.