How-to: Change an Instance Host Name

Change the host name of an Oracle Linux Compute VM instance using the following steps.

Note

Changes made in the /etc/hosts and resolv.conf files revert to their original values when the instance restarts, unless you complete the steps outlined here.
  1. Update the /etc/hostname file.
    hostnamectl set-hostname <new name>
  2. Edit the OCI configuration file and update the PRESERVE_HOSTINFO value to 2.
    sudo vi /etc/oci-hostname.conf
    PRESERVE_HOSTINFO=2
  3. Edit the VNIC host name in the OCI Console.
    • Go to Compute instances.
    • Select the instance. Do one of the following:
      • Select the Networking tab. Navigate to Attached VNICs.
      • Under Resources, select Attached VNICs.
    • For the target VNIC, from the Action Menu select Edit.
    • Change the VNIC host name as needed.
    • Select Save changes.
  4. Reboot the instance.
  5. Check the host name with hostname command.
  6. Check the host name and the Fully Qualified Domain Name (FQDN) with the following commands.
    host <ip address>
    or
    nslookup <ip address>
Note

The verification commands only work for a public IP address if the VCN is configured for public DNS resolution. Use the private IP address instead if public DNS isn't configured.
Important

The FQDN is configured using a combination of the VNIC host name, subnet name, and VCN name. For details on configuring DNS see: DNS in Your Virtual Cloud Network