Adding Your Own DNS Server to Your Virtual Subnet

In this Article:

When you create a virtual subnet in your cloud, you may want to use your own domain name system (DNS) service instead of the one that Metacloud automatically launches with the subnet. For example, you may want to resolve IP addresses with a DNS service outside of your cloud that hosts internal records for your organization.

If you are a Metacloud Administrator, you can add your own DNS server to your virtual subnet.

Using the Dashboard

You can specify your own DNS server when creating a new network or subnet, or updating an existing subnet. 

  1. Click Networks on the Project drop-down list.
  2. If you are creating a new network, click Create Network.
    If you are creating a subnet for an existing network, select the network and then click Create Subnet
    If you are updating an existing subnet, select the network, and then click Edit Subnet for the subnet you want to update.
  3. Click the Subnet Details tab.
  4. If you are creating a new network or subnet, enter the IP address of your DNS server, and click Save.
    If you are updating an existing subnet, overwrite the existing DNS server IP with your desired DNS server IP, and click Save.

    create_network_dns.png

Using the CLI

You can specify your own DNS server when creating a new subnet or updating an existing one.

For a new subnet:

1. View the list of available networks and note the network ID.

$ openstack network list
+--------------------------------------+---------------------------------+--------------------------------------+
| ID                                   | Name                            | Subnets                              |
+--------------------------------------+---------------------------------+--------------------------------------+
| <network_uuid>                       | network2                        |                                      |
| <network_uuid>                       | PUBLIC EXTERNAL - DO NOT MODIFY | <subnet_uuid>                        |
+--------------------------------------+---------------------------------+--------------------------------------+

2. Create a new subnet with your DNS server IP. Verify that the subnet is using your DNS server IP.

$ openstack subnet create subnet2 --dns-nameserver <YOUR_DNS_IP> --subnet-range <SUBNET_IP_RANGE> --network <NETWORK_UUID>
+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| allocation_pools  | <pool_ip_range>                      |
| cidr              | <subnet_ip_range>                    |
| created_at        | None                                 |
| description       | None                                 |
| dns_nameservers   | <YOUR_DNS_IP>                        |
| enable_dhcp       | True                                 |
| gateway_ip        | <IP>                                 |
| host_routes       |                                      |
| id                | <subnet_uuid>                        |
| ip_version        | 4                                    |
| ipv6_address_mode | None                                 |
| ipv6_ra_mode      | None                                 |
| name              | subnet2                              |
| network_id        | <network_uuid>                       |
| project_id        | <project_uuid>                       |
| revision_number   | None                                 |
| segment_id        | None                                 |
| service_types     | None                                 |
| subnetpool_id     | None                                 |
| updated_at        | None                                 |
+-------------------+--------------------------------------+

For an existing subnet:

1. View the ID of the subnet that you want your DNS server to run on.

$ openstack subnet list
+---------------------------------+-------------------------------+----------------------------------+------------------+
| ID                              | Name                          | Network                          | Subnet           |
+---------------------------------+-------------------------------+----------------------------------+------------------+
| <subnet_uuid>                   | PUBLIC SUBNET - DO NOT MODIFY | <network_uuid>                   | 184.94.253.64/26 |
| <subnet_uuid>                   | subnet1                       | <network_uuid>                   | 192.168.1.0/24   |
+---------------------------------+-------------------------------+----------------------------------+------------------+

2. Use the openstack subnet show command to check if the subnet has a DNS server assigned, such as one automatically launched by Metacloud when the subnet was created. If a DNS server has not been assigned, the dns_nameservers field is blank.

$ openstack subnet show <INTERNAL_SUBNET_UUID>
+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| allocation_pools  | <pool_ip_range>                      |
| cidr              | <subnet_ip_range>                    |
| created_at        | None                                 |
| description       | None                                 |
| dns_nameservers   | <current_dns_ip>                     |
| enable_dhcp       | True                                 |
| gateway_ip        | <IP>                                 |
| host_routes       |                                      |
| id                | <subnet_IP>                          |
| ip_version        | 4                                    |
| ipv6_address_mode | None                                 |
| ipv6_ra_mode      | None                                 |
| name              | subnet2                              |
| network_id        | <network_uuid>                       |
| project_id        | <project_uuid>                       |
| revision_number   | None                                 |
| segment_id        | None                                 |
| service_types     | None                                 |
| subnetpool_id     | None                                 |
| updated_at        | None                                 |
+-------------------+--------------------------------------+

3. Update the subnet to recognize your DNS server, using the --dns-nameserver parameter. To replace an existing DNS server, add the --no-dns-nameservers parameter.

$ openstack subnet set --dns-nameserver <YOUR_DNS_IP> --no-dns-nameservers <SUBNET_UUID>

4. Verify that the subnet recognizes your DNS server.

$ openstack subnet show <SUBNET_UUID>
+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| allocation_pools  | <pool_ip_range>                      |
| cidr              | <subnet_ip_range                     |
| created_at        | None                                 |
| description       | None                                 |
| dns_nameservers   | <YOUR_DNS_IP>                        |
| enable_dhcp       | True                                 |
| gateway_ip        | <gateway_ip>                         |
| host_routes       |                                      |
| id                | <subnet_uuid>                        |
| ip_version        | 4                                    |
| ipv6_address_mode | None                                 |
| ipv6_ra_mode      | None                                 |
| name              | subnet2                              |
| network_id        | <network_uuid>                       |
| project_id        | <project_uuid>                       |
| revision_number   | None                                 |
| segment_id        | None                                 |
| service_types     | None                                 |
| subnetpool_id     | None                                 |
| updated_at        | None                                 |
+-------------------+--------------------------------------+

Testing the Connection to the DNS Server

Verify that the DNS server you added to your subnet can resolve domain names. You can use different tools for testing, depending on the operating system (OS) of your VM. The following steps involve using nslookup on a VM with an Ubuntu 14.04 OS. 

To test your DNS server connection:

1. Reboot a VM in the subnet to make sure it applies the change that you made to the subnet.

$ openstack server reboot <VM_NAME>

2. Access the VM.

$ ssh -i <PEM_KEY_NAME> cloud@<VM_FLOATING_IP>

3. Confirm that the VM's DNS resolver is referencing the DNS IP address you added.

$ cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver <YOUR_DNS_IP>
search novalocal

4. If dnsutils is not running on the VM, install the package.

$ sudo apt-get -y install dnsutils

5. Query a domain name to see if your DNS server can resolve it.

$ nslookup cisco.com
Server:        208.67.222.222
Address:    208.67.222.222#53

Non-authoritative answer:
Name:    cisco.com
Address: 72.163.4.161

If the output of the query displays the IP address of the site, the DNS server can resolve domain names.

Have more questions? Submit a request
Powered by Zendesk