mr-karan / doggo

:dog: Command-line DNS Client for Humans. Written in Golang
https://doggo.mrkaran.dev/
GNU General Public License v3.0
2.83k stars 100 forks source link

Configure doggo to look up A *and* AAAA when not asked for any specific record type #124

Open nogweii opened 2 months ago

nogweii commented 2 months ago

When I type doggo example.com, I would like to see both A and AAAA records (properly indicated, of course). That's pretty similar to what most software does (thanks to them delegating to glibc, etc).

Probably as a CLI flag?

mr-karan commented 2 months ago

It's a bit arbitrary to show AAAA records along with A. If it makes sense, you can alias/make a bash function to do the same? doggo A AAAA

nogweii commented 2 months ago

I'd also argue it's a bit arbitrary to only show A. Especially with the recent pushes to move more and more to IPv6, I think it's time to re-evaluate that particular default. IPv4 won't go away, so showing only AAAA and not A wouldn't be correct.

I want to refer back to glibc's getnameinfo(3), it looks up both record types for the calling application. Which means most applications implicitly use IPv6 without any special configuration, and could cause confusion with dns tools: doggo example.com returns an IPv4 address but the application actually connected to an IPv6 address. (How often that actually matters is probably quite rare these days. Most dual-stacks are the same host.)

I'm not expecting the default to change yet (even if I think it should), but was asking for a way to easily enable showing both-by-default. I see three options:

  1. Actually change the default
  2. Add a CLI flag that sets this, maybe... doggo -b example.com? ("b" for both 😆)
  3. Instead of a flag, maybe an environment variable? DOGGO_DEFAULT_BOTH?

I might be missing something, but that's my perspective.

mr-karan commented 2 months ago

Noted. 2 or 3 should be possible. Not willing to change default behaviour just after a major release. 😅

daenney commented 2 months ago

systemd's resolvectl will query for both if a type is not specified:

$ resolvectl query google.com

google.com: 2a00:1450:400f:800::200e
            142.250.74.14

nslookup shares that behaviour:

$ nslookup google.com                                                                  

Non-authoritative answer:
Name:   google.com
Address: 142.250.74.14
Name:   google.com
Address: 2a00:1450:400f:800::200e

Despite dig and nslookup typically being provided by the BIND package on Linux, dig goes A only by default whereas nslookup seem to lookup both.

rohit1kumar commented 2 months ago

Hi @mr-karan If anyone else is not working I would like to pick it up.

mr-karan commented 2 months ago

Hey. I was re-thinking about this, and adding a vague flag like --both (esp when there are so many record types) is not clear. Additionally, I've also added --any flag which queries all common record types.

So, I think 1) changing the default to show both A and AAAA should be alright? Also, now that the resolver lookup is concurrent, this shouldn't affect the default query latency too much either.

So, I am okay to change the default query type from just A to A and AAAA both, aligning with nslookup / resolvectl.

@rohit1kumar You're free to pick this up, thanks.