Skip to content

CNAMEs return A record when original query is for AAAA; #1464

@speedst3r

Description

@speedst3r

Describe the bug
When querying a hostname (in a hosted zone) with type AAAA, if the response is a CNAME then the second response returns an A record instead of AAAA.

To Reproduce
Steps to reproduce the behavior:

  1. Setup hostname with A and AAAA results; setup CNAME to that hostname
  2. Query record that returns a CNAME with type AAAA
  3. Response is an A record, not AAAA
  4. Querying record with type A returns A record
  5. Querying the target record of the CNAME returns the correct record type for the query

Expected behavior
Second response to a query returning a CNAME should return the record type of the original query

Screenshots
Querying Gravity

$ dig @192.168.0.252 www.example.com

; <<>> DiG 9.18.30-0ubuntu0.24.04.1-Ubuntu <<>> @192.168.0.252 www.example.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 10157
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4000
;; QUESTION SECTION:
;www.example.com.              IN      A

;; ANSWER SECTION:
www.example.com.       0       IN      CNAME   example.com.
example.com.           0       IN      A       192.168.0.238

;; Query time: 0 msec
;; SERVER: 192.168.0.252#53(192.168.0.252) (UDP)
;; WHEN: Fri Jan 24 09:00:38 AWST 2025
;; MSG SIZE  rcvd: 115

$ dig @192.168.0.252 www.example.com a

; <<>> DiG 9.18.30-0ubuntu0.24.04.1-Ubuntu <<>> @192.168.0.252 www.example.com a
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 46385
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4000
;; QUESTION SECTION:
;www.example.com.              IN      A

;; ANSWER SECTION:
www.example.com.       0       IN      CNAME   example.com.
example.com.           0       IN      A       192.168.0.238

;; Query time: 0 msec
;; SERVER: 192.168.0.252#53(192.168.0.252) (UDP)
;; WHEN: Fri Jan 24 09:00:41 AWST 2025
;; MSG SIZE  rcvd: 115

$ dig @192.168.0.252 www.example.com aaaa

; <<>> DiG 9.18.30-0ubuntu0.24.04.1-Ubuntu <<>> @192.168.0.252 www.example.com aaaa
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12548
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4000
;; QUESTION SECTION:
;www.example.com.              IN      AAAA

;; ANSWER SECTION:
www.example.com.       0       IN      CNAME   example.com.
example.com.           0       IN      A       192.168.0.238

;; Query time: 0 msec
;; SERVER: 192.168.0.252#53(192.168.0.252) (UDP)
;; WHEN: Fri Jan 24 09:00:43 AWST 2025
;; MSG SIZE  rcvd: 115

$ dig @192.168.0.252 example.com

; <<>> DiG 9.18.30-0ubuntu0.24.04.1-Ubuntu <<>> @192.168.0.252 example.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 43914
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4000
;; QUESTION SECTION:
;example.com.                  IN      A

;; ANSWER SECTION:
example.com.           0       IN      A       192.168.0.238

;; Query time: 1 msec
;; SERVER: 192.168.0.252#53(192.168.0.252) (UDP)
;; WHEN: Fri Jan 24 09:00:48 AWST 2025
;; MSG SIZE  rcvd: 69

$ dig @192.168.0.252 example.com a

; <<>> DiG 9.18.30-0ubuntu0.24.04.1-Ubuntu <<>> @192.168.0.252 example.com a
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 41909
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4000
;; QUESTION SECTION:
;example.com.                  IN      A

;; ANSWER SECTION:
example.com.           0       IN      A       192.168.0.238

;; Query time: 1 msec
;; SERVER: 192.168.0.252#53(192.168.0.252) (UDP)
;; WHEN: Fri Jan 24 09:00:50 AWST 2025
;; MSG SIZE  rcvd: 69

$ dig @192.168.0.252 example.com aaaa

; <<>> DiG 9.18.30-0ubuntu0.24.04.1-Ubuntu <<>> @192.168.0.252 example.com aaaa
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 62397
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4000
;; QUESTION SECTION:
;example.com.                  IN      AAAA

;; ANSWER SECTION:
example.com.           0       IN      AAAA    2400:aaaa:bbbb:cccc:dddd:eeee::0

;; Query time: 1 msec
;; SERVER: 192.168.0.252#53(192.168.0.252) (UDP)
;; WHEN: Fri Jan 24 09:00:52 AWST 2025
;; MSG SIZE  rcvd: 81

Querying DNSmasq:

$ dig www.example.com a

; <<>> DiG 9.18.30-0ubuntu0.24.04.1-Ubuntu <<>> www.example.com a
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 45239
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;www.example.com.              IN      A

;; ANSWER SECTION:
www.example.com.       0       IN      CNAME   example.com.
example.com.           0       IN      A       192.168.0.238

;; Query time: 1 msec
;; SERVER: 127.0.0.53#53(127.0.0.53) (UDP)
;; WHEN: Fri Jan 24 09:04:41 AWST 2025
;; MSG SIZE  rcvd: 75

$ dig www.example.com aaaa

; <<>> DiG 9.18.30-0ubuntu0.24.04.1-Ubuntu <<>> www.example.com aaaa
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2309
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;www.example.com.              IN      AAAA

;; ANSWER SECTION:
www.example.com.       0       IN      CNAME   example.com.
example.com.           0       IN      AAAA    2400:aaaa:bbbb:cccc:dddd:eeee::0

;; Query time: 1 msec
;; SERVER: 127.0.0.53#53(127.0.0.53) (UDP)
;; WHEN: Fri Jan 24 09:04:43 AWST 2025
;; MSG SIZE  rcvd: 87

Logs
Output of docker-compose logs or kubectl logs respectively

Version and Deployment (please complete the following information):

  • Gravity version: 0.26.1
  • Deployment: kubernetes statefulset, external etcd

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions