How to Change Hostname in Oracle Cloud Infrastructure (OCI) Compute Environment on Oracle Linux Permanently

I wanted to change the host name for OCI Compute VM. I have below method to change the same

For Oracle Linux previous to version 7


1: Edit /etc/sysconfig/network

change the parameter value for "hostname"

# cat /etc/sysconfig/network
HOSTNAME=funebs-ol6 <--------- change here

2: In the file /etc/oci-hostname.conf change the value of PRESERVE_HOSTINFO to 2.


This change will be persistent across reboots.

For Oracle Linux 7 and later versions


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
    save the changes.

3: Edit the FQDN from OCI console GUI

a) Go to compute instances --> select the instance --> scroll down --> at the left bottom corner select attached VNIC under resources

b) Edit appropriate VNIC

c)  Change hostname to update FQDN--> update VNIC click save changes.

4: Reboot the instance

5: Check the hostname with hostname command.

6: Check if FQDN is resolving.

    host <ip address>
    nslookup <ip address>

If you like please follow and comment