If your Oracle Cloud Infrastructure (OCI) Linux instance isn’t resolving private DNS zones, the culprit is often the configuration of systemd-resolved. This guide walks you through two reliable methods to verify and correct DNS settings on an OCI‑hosted Linux server, ensuring that private DNS zones resolve correctly.
Method 1 – Adjust systemd‑resolved Settings (Ubuntu)
Step 1: Check the Current DNS Server
Before making any changes, verify the active DNS configuration:
resolvectl status
The output lists the DNS servers in use. In OCI, the default DNS server is usually 169.254.169.254. Note the address for the next step.
Step 2: Edit systemd-resolved Configuration
Open the resolver configuration file with your preferred editor:
sudo nano /etc/systemd/resolved.conf
Find the DNS and Domains lines and update them as needed:
DNS=169.254.169.254
Domains=localdomain.local
Make sure the DNS entry matches the address you observed in Step 1.
Step 3: Disable the DNS Stub Listener (Optional)
If DNS resolution still fails, the local stub listener may be interfering. Disable it by adding or ensuring the following line exists in resolved.conf:
DNSStubListener=no
Step 4: Restart systemd-resolved
Apply the changes by restarting the service:
sudo systemctl restart systemd-resolved
Method 2 – Make /etc/resolv.conf Immutable
Step 1: Replace and Lock the Resolve File
This approach forces the server to use public DNS servers and prevents OCI from overwriting the file:
sudo rm -f /etc/resolv.conf
echo -e "nameserver 8.8.8.8\nnameserver 8.8.4.4" | sudo tee /etc/resolv.conf
sudo chattr +i /etc/resolv.conf
The chattr +i command makes resolv.conf immutable, so subsequent OCI agent updates won’t replace your custom settings.
By following either of these methods, you should restore proper resolution of private DNS zones on your Oracle Cloud Linux server. If problems persist, double‑check the OCI DNS policies and ensure that your VCN’s DNS settings allow the desired private zones.
