Symptom
One instance can't reach another by name, but the private IP works:
$ ping app01
ping: app01: Name or service not known
$ dig +short app01.app.prodvcn.oraclevcn.com
$ # empty answer
Other variants of the same problem:
- A new instance has no
*.oraclevcn.comname at all. - After you renamed a server with
hostnamectl, other servers still resolve the old name or none. - Names resolve inside one VCN but not from a peered VCN or from on-prem.
Inside a VCN, OCI builds each instance's name from three labels:
<vnic hostname label>.<subnet DNS label>.<VCN DNS label>.oraclevcn.com
If any of the three is missing, there's no record. If the instance doesn't use the VCN resolver, it never sees the record. Work through the checks below in order.
Quick diagnosis
| Symptom | Likely cause | Fix |
|---|---|---|
| No instance in the subnet has a FQDN | VCN or subnet created without a DNS label | Labels can't be added later; create a new subnet (or VCN) with labels |
| One instance has no FQDN | VNIC has no hostname label | oci network vnic update --hostname-label |
| Old name still resolves after rename | DNS follows the VNIC label, not the OS hostname | Update the VNIC hostname label |
| FQDN works, short name doesn't | Search domain missing from DHCP options or resolv.conf | Add the subnet and VCN domains as search domains |
Nothing in oraclevcn.com resolves | Instance uses a custom DNS server | Use the VCN resolver, or forward oraclevcn.com to it |
| Works in VCN A, fails from VCN B | VCN B's resolver doesn't know VCN A's private view | Attach VCN A's view to VCN B's resolver |
| Fails from on-prem only | No resolver listening endpoint or no on-prem forwarder | Add a listening endpoint and a conditional forwarder |
1. Check the VCN and subnet DNS labels
VCN=ocid1.vcn.oc1..xxxx
SUBNET=ocid1.subnet.oc1..xxxx
oci network vcn get --vcn-id $VCN \
--query 'data.{name:"display-name",label:"dns-label",domain:"vcn-domain-name"}'
oci network subnet get --subnet-id $SUBNET \
--query 'data.{name:"display-name",label:"dns-label",domain:"subnet-domain-name"}'
If dns-label is null on the VCN or the subnet, instances in that subnet get no VCN DNS names. A subnet can only have a DNS label if its VCN has one.
Warning
You set DNS labels when you create the VCN or subnet, and you can't add or change them afterwards. The fix is a new subnet with a label, then moving the instances: create a new VNIC in the new subnet, or rebuild from the boot volume. Plan this as a change with downtime, not a quick fix.
For new networks, always pass the labels:
oci network vcn create -c $COMPARTMENT --cidr-blocks '["10.10.0.0/16"]' \
--display-name prod-vcn --dns-label prodvcn
oci network subnet create -c $COMPARTMENT --vcn-id $VCN \
--cidr-block 10.10.1.0/24 --display-name app --dns-label app \
--prohibit-public-ip-on-vnic true
Labels must start with a letter, use only letters and digits, and be short. Check the current length limit in the CLI help.
2. Check the VNIC hostname label
INSTANCE=ocid1.instance.oc1..xxxx
oci compute vnic-attachment list -c $COMPARTMENT --instance-id $INSTANCE \
--query 'data[].{"vnic":"vnic-id",state:"lifecycle-state"}' --output table
VNIC=ocid1.vnic.oc1..xxxx
oci network vnic get --vnic-id $VNIC \
--query 'data.{ip:"private-ip",hostname:"hostname-label",subnet:"subnet-id"}'
If hostname-label is empty, set it. It must be unique within the subnet.
oci network vnic update --vnic-id $VNIC --hostname-label app01
For a secondary private IP that needs its own name, set the label on the private IP object:
oci network private-ip list --vnic-id $VNIC --output table
oci network private-ip update --private-ip-id ocid1.privateip.oc1..xxxx --hostname-label app01-vip
To give an instance a predictable name at launch, pass --hostname-label to oci compute instance launch. Don't rely on the display name.
3. Check which resolver the instance uses
On Linux:
cat /etc/resolv.conf
# expected: nameserver 169.254.169.254
# search app.prodvcn.oraclevcn.com prodvcn.oraclevcn.com
dig @169.254.169.254 +short app01.app.prodvcn.oraclevcn.com
On Windows (PowerShell):
Get-DnsClientServerAddress -AddressFamily IPv4
Resolve-DnsName app01.app.prodvcn.oraclevcn.com -Server 169.254.169.254
If the query against 169.254.169.254 works but plain lookups fail, the instance is using another DNS server. Check the subnet's DHCP options:
oci network subnet get --subnet-id $SUBNET --query 'data."dhcp-options-id"' --raw-output \
| xargs -I{} oci network dhcp-options get --dhcp-id {} --query 'data.options'
"serverType": "VcnLocalPlusInternet" means the VCN resolver is in use. CustomDnsServer means your own DNS servers. These must forward oraclevcn.com (and your private zones) to the VCN resolver, or VCN names won't resolve.
Caution
Changing DHCP options affects every instance in every subnet that uses them, at their next DHCP lease renewal or reboot. Test on a dedicated subnet first, and keep the old option set so you can switch back.
If the short name fails but the FQDN works, the search domain is missing. Add a SearchDomain entry with the subnet and VCN domains to the DHCP options, or set it in the OS network configuration.
4. Renamed the OS hostname? DNS didn't follow
hostnamectl set-hostname changes only the OS. The VCN record still comes from the VNIC hostname label. To rename properly:
- Update the VNIC:
oci network vnic update --vnic-id $VNIC --hostname-label app02. - Set the OS hostname:
sudo hostnamectl set-hostname app02. - On OCI Oracle Linux images, edit
/etc/oci-hostname.confand setPRESERVE_HOSTINFO=2, as Oracle's "Change an Instance Host Name" guide describes. Otherwise the image's scripts can rewrite the hostname and/etc/hostsat boot. Read the comments in the file for what each value keeps. Behaviour varies by image version. - Reboot once and confirm with
hostname -fand a lookup from another instance.
Update application configs, monitoring targets and SSH known_hosts entries that used the old name.
5. Lookups from another VCN or from on-prem
Each VCN's resolver answers only from the private views attached to it. Its own default view holds that VCN's oraclevcn.com records. To resolve VCN A's names from VCN B, attach VCN A's default view to VCN B's resolver:
oci network vcn-dns-resolver-association get --vcn-id $VCN_B \
--query 'data."dns-resolver-id"' --raw-output
oci dns resolver get --resolver-id $RESOLVER_B --scope PRIVATE \
--query 'data."attached-views"' > views.json
# add {"viewId": "<VCN A default view OCID>"} to views.json, keep existing entries
oci dns resolver update --resolver-id $RESOLVER_B --scope PRIVATE \
--attached-views file://views.json --force
--attached-views is the complete list. Leaving out an existing view stops those names resolving in VCN B. Network peering (LPG or DRG) doesn't share DNS on its own. You still need the view attachment.
On-prem clients need a resolver listening endpoint in the VCN and a conditional forwarder for oraclevcn.com on the on-prem DNS servers. The private DNS at scale post covers that setup.
Prevent it next time
- Make DNS labels mandatory in your Terraform modules for
oci_core_vcnandoci_core_subnet, and fail the plan if they're missing. - Set
hostname_labelexplicitly in instance and instance configuration templates. - Treat DHCP option changes as network changes: review, test on one subnet, keep a rollback.
- Add a scheduled check that resolves a few known FQDNs from each VCN, and alarm when they return nothing.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get