Oracle recently introduced private DNS services as a new feature for Oracle Cloud Infrastructure (OCI). Private DNS lets you access DNS data from resources inside a virtual cloud network (VCN).
A private DNS zone provides services similar to those provided by a public DNS zone, but it provides them only to requests that come from clients hosted in the VCN. With OCI DNS Management, you can provision a split-horizon DNS configuration, which lets you use the same domain name for public and private use.
In this post, I show you how to configure a split-horizon DNS zone. You can use any published DNS zone in OCI or elsewhere. In a previous blog post, I explained how to configure an internet DNS zone. Here, I use the internet DNS zone from that post, which is castro.cloud, and add the private DNS portion to complete the split-horizon configuration.
The public IP address for the A record in castro.cloud is now 22.214.171.124. Everything else remains as configured in the previous post.
The castro.cloud and www.castro.cloud domains have been published, and are accessible through the open internet (until February 28, 2021).
To create a private DNS zone, you need to be in a group that has the following special policy permission:
You can access internet and private DNS zones in the OCI Console by navigating to Networking and then DNS Management in the main menu.
In the DNS Management menu, click Zones to see internet DNS zones, and click Private Views to see private DNS zones.
You can also see private DNS zones from the details for a VCN.
Follow these steps to create the private DNS zone.
Before you create the private DNS zone, you need to get the private IP address of the webserver that hosts the internet DNS zone, in this example castro.cloud. The following image shows that the IP address of the server is 10.0.0.3 and that the server is in the public subnet.
In this example, the VCN that hosts the castro.cloud webserver is named Sites. To see the details of this VCN, click the Sites link under Instance Details.
This VCN was created with the VCN wizard. The IP address CIDR prefixes for the VCN and its subnets are the standard ones that the VCN wizard assigns:
This information is shown in the following image.
To configure the private DNS, click the Sites link next to DNS Resolver.
Notice the message on the Private Resolver Information tab:
“A private DNS resolver handles DNS queries within your VCN based on private views and the private zones they contain. A private DNS zone has similar capabilities to an Internet DNS zone, but provides responses only for clients that can reach it through a VCN.”
The private DNS resolver provides a view for several private DNS zones.
To create the private DNS zone for castro.cloud, click the link next to Default Private View, which is Sites in this example.
The zones that already exist are provisioned by default when the VCN is created. Notice that two of the zone names are the DNS domain names of the subnets. If you expand them, you see NS, SOA, and PTR records.
Click Create Zone.
For Zone Name, enter the private DNS zone that matches the internet DNS zone, in this case castro.cloud. Then, click Create.
The new private DNS zone is created.
Next, click Add Record and create an A record that maps castro.cloud to the webserver’s private IP address, which is 10.0.0.3.
The zone details page lists the A record.
The next step is to publish this new private DNS zone. Before you do, you can optionally add another record for placing www in front of the naked domain name. This example skips that step.
Click Publish Changes. You have successfully created a split-horizon configuration on OCI!
Notice the tabs for switching views between your public internet DNS zones and your private DNS zones.
To test the new split-horizon configuration, add a new public subnet to the VCN and a compute instance on it.
The security list on the current public subnet, where the webserver resides, allows traffic from anywhere to port 80.
To ensure that you’re reaching the private DNS and not the internet DNS, use strict security list rules on this new subnet. The new security rule allows egress traffic only to 10.0.0.3 on port 80.
Create the security list. In this example, it’s named PrivateDNS.
Next, assign this security list to the new subnet, which in this example is also named PrivateDNS. The subnet prefix is 10.0.100.0/24.
The default route table provides access to the internet gateway, which is used by this subnet for Remote Desktop Protocol (RDP).
No route table is required for reaching the webserver because routing within VCNs is automatically enabled in OCI.
Create a Windows instance in the subnet that you created. The following image shows the details of the instance created for this example. It was created in the PrivateDNS subnet of the Sites VCN, and its private IP address is 10.0.100.2.
Use Remote Desktop Connection to connect to the instance. The public IP address is 126.96.36.199.
After you connect, open a web browser and navigate to the private DNS zone, castro.cloud in this example.
In addition, run nslookup on castro.cloud from this Windows instance.
This split-horizon configuration lets internet users resolve your webserver’s domain from anywhere outside your VCN while letting your Oracle Cloud Infrastructure users resolve the same domain inside the VCN.
For DNS peering between VCNs in OCI see Private DNS Implementation by Javier Ramirez.