EmilHernvall / dnsguide

A guide to writing a DNS Server from scratch in Rust
MIT License
3.92k stars 246 forks source link

does not give proper IP address for non google domans #19

Closed coderboi2001 closed 2 years ago

coderboi2001 commented 2 years ago

`; <<>> DiG 9.16.26 <<>> @127.0.0.1 -p 2053 www.twitch.tv ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 50931 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 0

;; QUESTION SECTION: ;www.twitch.tv. IN A

;; ANSWER SECTION: www.twitch.tv. 3600 IN CNAME twitch.map.fastly.net.

;; AUTHORITY SECTION: twitch.tv. 172800 IN NS ns-1450.awsdns-53.org. twitch.tv. 172800 IN NS ns-1778.awsdns-30.co.uk. twitch.tv. 172800 IN NS ns-219.awsdns-27.com. twitch.tv. 172800 IN NS ns-664.awsdns-19.net.

;; Query time: 842 msec ;; SERVER: 127.0.0.1#2053(127.0.0.1) ;; WHEN: Mon Mar 14 00:06:10 India Standard Time 2022 ;; MSG SIZE rcvd: 255`

why is this happening?

coderboi2001 commented 2 years ago

` ; <<>> DiG 9.16.26 <<>> @127.0.0.1 -p 2053 www.gmail.com ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20958 ;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION: ;www.gmail.com. IN A

;; ANSWER SECTION: www.gmail.com. 86400 IN CNAME mail.google.com. mail.google.com. 86400 IN CNAME googlemail.l.google.com. googlemail.l.google.com. 300 IN A 142.250.182.69

;; Query time: 538 msec ;; SERVER: 127.0.0.1#2053(127.0.0.1) ;; WHEN: Mon Mar 14 00:08:51 India Standard Time 2022 ;; MSG SIZE rcvd: 164 `

EmilHernvall commented 2 years ago

What specifically is the issue? The absence of an A-record in the answer-section? Some authoritative servers doesn't include A-records when they respond with a CNAME. Most recursive resolvers will then perform another query to find the A record for the CNAME, but to keep things simple, this guide doesn't cover bells and whistles like that.

coderboi2001 commented 2 years ago

it works if i remove the www. thank you for the answer