Always fill in the DNS Hostname Prefix when creating a new instance in Oracle Compute Cloud.
What seems an unimportant optional field can make your life harder than it should be, namely your instance will get a new hostname and new server ssh key each time the instance orchestration is restarted, which leads to confusion and problems. Here’s why that happens:
Each instance is governed by Instance Metadata. There is actually a server available to your instance on the internal network, where Metadata is available. Among other things, the Metadata contains server DNS name.
Here’s the important part: if you leave DNS Hostname Prefix field empty, then DNS name is dynamic, auto generated each time the instance orchestration is started (but not when instance is rebooted).
On your instance, there’s also /usr/bin/opc-linux-init script started by /etc/rc.d/rc.local, at least if your instance is based on one of the predefined Oracle images.
This script checks if the hostname is the same as the one provided by the Metadata - and if it’s not, it changes the hostname, server ssh keys and possibly other instance configuration.
There are probably not many scenarios when you want your instance to be reconfigured on each start, so remember to configure DNS Hostname Prefix when you create it. If you need to update one of your existing instances, add "dns" : [ „yourhostname“ ] to the instance networking configuration.