Configuring DNS Servers
DNS Overview
Domain Name System (DNS) is the standard protocol for resolving domain names into IP addresses so that traffic can be routed to its destination. DNS provides the translation between human-readable domain names and their IP addresses. The domain names are defined in a hierarchical tree, with a root followed by top-level and next-level domain labels.
A DNS server stores the records for a domain name and responds to queries from clients based on these records. The server is authoritative for the domains for which it is configured to be the name server. For other domains, the server can act as a caching server, fetching the records by querying other domain name servers.
The following are the key attributes of domain name service in a virtual world:
It should be possible to configure multiple domain name servers to provide name resolution service for the virtual machines spawned in the system.
It should be possible to configure the domain name servers to form DNS server hierarchies required by each tenant.
The hierarchies can be independent and completely isolated from other similar hierarchies present in the system, or they can provide naming service to other hierarchies present in the system.
DNS records for the virtual machines spawned in the system should be updated dynamically when a virtual machine is created or destroyed.
The service should be scalable to handle an increase in servers and the resulting increased numbers of virtual machines and DNS queries handled in the system.
Defining Multiple Virtual Domain Name Servers
Contrail provides the flexibility to define multiple virtual domain name servers under each domain in the system. Each virtual domain name server is an authoritative server for the DNS domain configured. Figure 1 shows examples of virtual DNS servers defined in default-domain, providing the name service for the DNS domains indicated.
IPAM and Virtual DNS
Each IP address management (IPAM) service in the system can refer to one of the virtual DNS servers configured. The virtual networks and virtual machines spawned are associated with the DNS domain specified in the corresponding IPAM. When the VMs are configured with DHCP, they receive the domain assignment in the DHCP domain-name option. Examples are shown in Figure 2
DNS Record Types
DNS records can be added statically. DNS record types A, CNAME, PTR, and NS are currently supported in the system. Each record includes the type, class (IN), name, data, and TTL values. See Table 1 for descriptions of the record types.
DNS Record Type |
Description |
---|---|
A |
Used for mapping hostnames to IPv4 addresses. Name refers to the name of the virtual machine, and data is the IPv4 address of the virtual machine. |
CNAME |
Provides an alias to a name. Name refers to the name of the virtual machine, and data is the new name (alias) for the virtual machine. |
PTR |
A pointer to a record, it provides reverse mapping from an IP address to a name. Name refers to the IP address, and data is the name for the virtual machine. The address in the PTR record should be part of a subnet configured for a VN within one of the IPAMs referring to this virtual DNS server. |
NS |
Used to delegate a subdomain to another DNS server. The DNS server could be another virtual DNS server defined in the system or the IP address of an external DNS server reachable via the infrastructure. Name refers to the subdomain being delegated, and data is the name of the virtual DNS server or IP address of an external server. |
Figure 3 shows an example usage for the DNS record type of NS.
Configuring DNS Using the Interface
DNS can be configured by using the user interface or by using scripts. The following procedure shows how to configure DNS through the Juniper Networks Contrail interface.
Configuring DNS Using Scripts
You can configure DNS by using scripts that are available in the contrail-utils RPM/DEB package in the /opt/contrail/utils directory. The scripts are copied to the config_api_container or config node when you install the contrail-utils RPM/DEB package. You can execute the scripts from either the config_api container or the config node. The scripts are described in Table 6.
Be aware of the following cautions when using scripts to configure DNS:
DNS doesn’t allow special characters in the names, other than - (dash) and . (period). Any records that include special characters in the name will be discarded by the system.
The IPAM DNS mode and association should only be edited when there are no virtual machine instances in the virtual networks associated with the IPAM.
Action |
Script |
---|---|
Add a virtual DNS server |
Script: Sample usage: |
Delete a virtual DNS server |
Script: Sample usage: |
Add a DNS record |
Script: Sample usage: |
Delete a DNS record |
Script: Sample usage: |
Associate a virtual DNS server with an IPAM |
Script: Sample usage: |
Disassociate a virtual DNS server with an IPAM |
Script: Sample usage: |