knadh/dns.toys

Explicit IPv4 support

guptayash opened this issue · 4 comments

Currently, in the case of dual-stack (where v4 and v6 are assigned) dig ip @dns.toys always returns a v6 address. It would be great to have the IP query return the v4 address when mentioned.

I am willing to work on this.

knadh commented

I'm not sure how the net lib behaves with dual stack IPs, but guessing killing the switch{} and splitting the cases to two if conditions should work. I've no way of testing this. Please feel free to send a PR if you're able to test this.

https://github.com/knadh/dns.toys/blob/master/cmd/dnstoys/handlers.go#L110

Hey @knadh, sorry for delay in response. I figured that my DNS server is returning AAAA record for dns.toys and hence my request to dns.toys is always going via IPv6. Hence, there is no way for us to return IPv4 if the request is made over IPv6.
Would love to hear your thoughts and close this issue.

knadh commented

I figured that my DNS server is returning AAAA record for dns.toys and hence my request to dns.toys is always going via IPv6. Hence, there is no way for us to return IPv4 if the request is made over IPv6.

Yep.

For the interested reader who lands here via search:

# IPv4
dig -4 ip @dns.toys

# IPv6
dig -6 ip @dns.toys