DNS TXT and MX Record
Overview
DNS virtual service on Avi Vantage primarily implements the following functionality:
- DNS Load Balancing
- Hosting Manual or Static DNS Entries
- Virtual Service IP Address DNS Hosting
- Hosting GSLB Service DNS Entries
Avi DNS can host manual static DNS entries. For a given FQDN, you can configure an A, AAAA, SRV, CNAME, or NS record to be returned. Starting with Avi Vantage release 20.1.1, Avi Vantage supports text record (TXT) record and mail exchanger (MX) record.
- TXT record: This is used to store text-based information of the outside domain for the configured domain. This is useful in identifying ownership of a domain.
- MX record: This is used in mail delivery based on the configured domain. This is useful in redirecting email requests to the mail servers for a specified domain.
Configuring DNS TXT Record
Login to Avi CLI and use the static_dns_records
option from the configure virtualservice
mode to add a TXT record for the desired domain as shown below.
In the following example, the favorite-protocol=DNS test is used as a DNS TXT record for the domain txtrec.acme.com.
[admin:controller]: > configure virtualservice VS-DNS
[admin:controller]: virtualservice> static_dns_records
New object being created
[admin:controller]: virtualservice:static_dns_records> fqdn txtrec.acme.com
[admin:controller]: virtualservice:static_dns_records> type dns_record_txt
[admin:controller]: virtualservice:static_dns_records> txt_records
New object being created
[admin:controller]: virtualservice:static_dns_records:txt_records> text_str "favorite_protocol=DNS"
[admin:controller]: virtualservice:static_dns_records:txt_records> save
[admin:controller: virtualservice:static_dns_records> save
[admin:controller]: virtualservice> save
Configuring DNS TXT Record with A or MX record
TXT record can be configured with any other existing record (for example, A record and MX record) with the same FQDN.
[admin:controller]: > configure virtualservice VS-DNS
[admin:controller]: virtualservice> static_dns_records index 1
[admin:controller]: virtualservice:static_dns_records>
[admin:controller]: virtualservice> static_dns_records index 1
[admin:controller]: virtualservice:static_dns_records> txt_records
New object being created
[admin:controller]: virtualservice:static_dns_records:txt_records> text_str "favorite_protocol=DNS"
[admin:controller]: virtualservice:static_dns_records:txt_records> save
[admin:controller]: virtualservice:static_dns_records> save
[admin:controller]: virtualservice> save
Configured TXT record data now respond to the appropriate DNS query. Use the following dig command to test the desired output.
aviuser@controller:~$ dig @10.140.135.22 txtrec.acme.com TXT
; <<>> DiG 9.10.3-P4-Ubuntu <<>> @10.140.135.22 txtrec.acme.com TXT
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 3327
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;txtrec.acme.com. IN TXT
;; ANSWER SECTION:
txtrec.acme.com. 30 IN TXT "favorite_protocol=DNS"
;; Query time: 2 msec
;; SERVER: 10.140.135.22#53(10.140.135.22)
;; WHEN: Tue Feb 25 10:42:59 UTC 2020
;; MSG SIZE rcvd: 66
Configuring DNS MX Record
For the MX record, a static DNS entry of type mx_records is added to redirect email requests to the designated mail server. The host (m1.vmware.com) used in the below example is the FQDN for the designated mail server.
[admin:controller]: > configure virtualservice VS-DNS
[admin:controller]: virtualservice> static_dns_records
[admin:controller]: virtualservice> static_dns_records
New object being created
[admin:controller]: virtualservice:static_dns_records> fqdn txtrec.acme.com
[admin:controller]: virtualservice:static_dns_records> type dns_record_mx
[admin:controller]: virtualservice:static_dns_records> mx_records
New object being created
[admin:controller]: virtualservice:static_dns_records:mx_records> host m1.acme.com
[admin:controller]: virtualservice:static_dns_records:mx_records> priority 10
[admin:controller]: virtualservice:static_dns_records:mx_records> save
[admin:controller]: virtualservice:static_dns_records> save
[admin:controller]: virtualservice> save
Note: The value for the priority field can vary from 0-65535
Configuring MX record with any other existing record
Use the following configuration to enable the MX record for the existing A record. In the below example, MS record for the m.foo.com is added for the existing A Record (foo.com).
[admin:controller]: > configure virtualservice VS-DNS
(INTEGER) Index of the Object (use where command to see index)
[admin:controller]: virtualservice> static_dns_records index 2
[admin:controller]: virtualservice:static_dns_records> where
Tenant: admin
Cloud: Default-Cloud
+-------------------------+---------------------------------+
| Field | Value |
+-------------------------+---------------------------------+
| fqdn[1] | acme.com |
| type | DNS_RECORD_A |
| ip_address[1] | |
| ip_address | 1.1.1.1 |
| num_records_in_response | 0 |
| algorithm | DNS_RECORD_RESPONSE_ROUND_ROBIN |
| wildcard_match | False |
| delegated | False |
+-------------------------+---------------------------------+
[admin:controller]: virtualservice:static_dns_records>
[admin:controller]: virtualservice:static_dns_records> mx_records
New object being created
[admin:controller]: virtualservice:static_dns_records:mx_records> host m.acme.com
[admin:controller]: virtualservice:static_dns_records:mx_records> priority 12
dmin:naveen-cntrlr]: virtualservice:static_dns_records:mx_records> save
sav[admin:controller]: virtualservice:static_dns_records> save
[admin:controller]: virtualservice> save
DNS queries to the VIP should now serve the record data thus configured .
aviuser@controller:~$ dig @10.140.135.22 txtrec.acme.com MX
; <<>> DiG 9.10.3-P4-Ubuntu <<>> @10.140.135.22 txtrec.acme.com MX
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 6518
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; WARNING: recursion requested but not available
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;txtrec.acme.com. IN MX
;; ANSWER SECTION:
txtrec.acme.com. 30 IN MX 10 m1.acme.com.
;; Query time: 1 msec
;; SERVER: 10.140.135.22#53(10.140.135.22)
;; WHEN: Tue Feb 25 09:40:59 UTC 2020
;; MSG SIZE rcvd: 72
aviuser@controller:~$