How-to: Change an Instance Host Name
You can change the host name of Compute VM instances.
Note
Changes made in the
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.To change the host name, use the following commands:
- Update the
/etc/hostname
file.hostnamectl set-hostname <new name>
- Edit the OCI configuration file and update the needed value to 2.
sudo vi /etc/oci-hostname.conf PRESERVE_HOSTINFO=2
- Edit the Fully Qualified Domain Name (FQDN) from the OCI
Console.
- Go to Compute instances.
- Select the instance.
- Under resources, select attached VNIC.
- From the Action Menu, select Edit.
- Change the host name to update the FQDN.
- Select Save changes.
- Reboot the instance.
- Check the host name with
hostname
command. - Check if FQDN is resolving.
host <ip address>
ornslookup <ip address>