-->
  • Recent Articles

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

    By design, changes made in the /etc/hosts and resolv.conf files revert to their original values, after an instance restart, unless these steps are implemented.

     

    SOLUTION

    For Oracle Linux: (prior to Version 7)


    1: Edit /etc/sysconfig/network

    change the parameter value for "hostname"

    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


    This change will be persistent across reboots.


    For Oracle Linux 7 :

    Steps to be followed in order to change the hostname on oel7 server persistently hosted on OCI environment.


    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.


    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


    OCI Instance VNIC Attachments
    OCI Instance VNIC Attachments

    OCI Instance VNIC hostname change
    OCI Instance VNIC hostname change


    4: Reboot the instance


    Testing:

    1: Check the hostname with hostname command.

    2: Check if FQDN is resolving.

        host <ip adress>

          or

        nslookup <ip adress>


    No comments