So I am trying to write a DNS resolver in JavaScript. It is working fine for cases like amazon.com and stanford.edu. However it is not working for some cases like example.com.
I also try to resolve it manually but it does not work. I have tried to summarize my approach below.
First, I’d like to introduce an online tool I’m using to follow the path being taken: https://manytools.org/network/query-dns-records-online/. This tool allows us to use a specific DNS nameserver. for the DNS resolution.
Here are the steps I followed to try to resolve it manually:
- I enter 198.41.0.4 as the DNS resolver and request an A record for example.com.
- Around 13 name servers are returned in the additional section. For example, one of
them is e.gtld-servers.net with the IP 192.12.94.30. There were 0 answers or
authority sections. - Now, one by one, for the returned 13 name servers, I try to resolve example.com for A
records. - For each of the 13 queries, I get answer, authority, and additional sections with
zero entries. - This is where I reach a dead end.
I hope my way of trying to resolve and my understanding are correct. If not, please let me know.
Following the same approach for other domains such as amazon.com or paypal.com leads to an answer.
So, when the manual approach is failing, how can I expect the code to work
Please help me identifying any mistakes i am making or what should be done. Thanks
Attaching my output log for a working case(example.com)
Resolving DNS for amazon.com at 198.41.0.4
query amazon.com.
Resolving DNS for amazon.com at 192.12.94.30
query amazon.com.
Resolving DNS for amazon.com at 156.154.64.10
query amazon.com.
FOUND!
decoded name amazon.com.
decoded A Record 54.239.28.85
Attaching my output log for a non-working case(example.com)
Resolving DNS for example.com at 198.41.0.4
query example.com.
Resolving DNS for example.com at 192.5.6.30
query example.com.