AdguardTeam / AdGuardHome

Network-wide ads & trackers blocking DNS server
https://adguard.com/adguard-home.html
GNU General Public License v3.0
24.77k stars 1.79k forks source link

Prefer IPv4/6. However, it does not affect the resolution of pure IPv6/4 domain names. #5919

Open 57382 opened 1 year ago

57382 commented 1 year ago

Prerequisites

The problem

prefer_ipv4 and prefer_ipv6 are two operations. In the following, for the convenience of expression, only prefer_ipv4 is taken as an example. prefer_ipv6 is the same. prefer_ipv4 Allows downstream clients to use IPv4 first when they support dual-stack. When prefer_ipv4 processes an AAAA request, it will automatically send an A request to test whether the domain name is dual-stack, and the newly generated A request will continue to execute subsequent rules together with the original AAAA request. If both A and AAAA requests get IP (the domain name is dual-stack) at last, the original AAAA request will be blocked.

Proposed solution

@ainar-g reference https://irine-sistiana.gitbook.io/mosdns-wiki/mosdns-v5/ru-he-pei-zhi-mosdns/sequence-cha-jian#prefer_ipv4-6

Alternatives considered and additional information

No response

57382 commented 1 year ago

I want to use prefer_ipv6. Currently AdGuardHome is only able to brute force disable ipv6, which is not what I want. In my network, ipv6 is 3 times faster than ipv4. I'm talking about 3x the bandwidth. That's why I don't want a ipv4.

57382 commented 1 year ago

Some backward websites only support IPv4. Therefore, IPv4 cannot be simply turned off.

fernvenue commented 1 year ago

Duplicate of https://github.com/AdguardTeam/AdGuardHome/discussions/4482.

57382 commented 1 year ago

Duplicate of #4482.

*$dnstype=A,dnsrewrite=NOERROR This will kill all A. This will kill all IPv4.

||internal.my-campus.edu^$dnstype=A,dnsrewrite=NOERROR This is not done automatically. Not as smart as prefer_ipv6. So this is also useless.

Some applications lack settings and they ignore the operating system's configuration. Therefore, it is necessary to implement this function in the DNS resolver.

ainar-g commented 1 year ago

@57382, I do not understand your request, sorry. The only preference we currently have is dns.bootstrap_prefer_ipv6, and it merely affects how the IP addresses for DNS servers are sorted.

57382 commented 1 year ago

@57382, I do not understand your request, sorry. The only preference we currently have is dns.bootstrap_prefer_ipv6, and it merely affects how the IP addresses for DNS servers are sorted.

@ainar-g

I want to add the following functionality: Suppose a domain name has both A records and AAAA records. This feature was added to allow forcing only AAAA records to be returned. This is achieved by deleting the A record. So it is mandatory. This feature is only available for domain names that have both A records and AAAA records. If there is only an A record for a domain name and no AAAA record, the A record will not be deleted and the A record will remain. This will avoid losing access to the domain if the A record is deleted.

vice versa. If I want to force only A records to be returned, the AAAA records are removed, but disabled for domains that only have AAAA records.

Another open source resolver, MOSDNS, has the above functions. MOSDNS uses the parameters prefer_ipv6 and prefer_ipv4 to achieve the above behavior. I wish AdGuardHome would do the same, instead of just brute force removing all A's or AAAA's, which would break a lot of domains. It is extremely cumbersome to use rules for each domain name.

You can refer to this part of code of MOSDNS, implemented for AdGuardHome. https://github.com/IrineSistiana/mosdns

ainar-g commented 1 year ago

I see. That would require us to essentially either query upstreams for both A and AAAA for a domain whenever one is queried or keep (and refresh) a list of domains which have one, both, or neither. I'm not sure if this is a common enough need to implement it. Whether to use AAAA results or the A ones is usually up to DNS clients.

57382 commented 1 year ago

I see. That would require us to essentially either query upstreams for both A and AAAA for a domain whenever one is queried or keep (and refresh) a list of domains which have one, both, or neither. I'm not sure if this is a common enough need to implement it. Whether to use AAAA results or the A ones is usually up to DNS clients.

As a client application it knows nothing. Sometimes one needs to override the behavior of the client application. It is beneficial to implement this functionality. It doesn't do any harm. Black and white list mode is also available for this purpose. This increases compatibility from 99% to 100%. Works on all sites. Accelerate the network silently. Details about implementing this functionality. Never use the domain name rule list method. Manually maintaining a list of domain name rules is very tedious. There are hundreds of millions of domain names on the Internet. The list of domain names should be used as a supplementary means in the form of black and white lists. rather than the implementation method for this functionality. Both should be queried at the same time. Allows users to customize the setting of a synchronization query parameter to specify how many seconds to wait. You can also use caching. Only one of them is cached. The above methods can be combined. This process must be fully automatic. The future belongs to IPv6, the future belongs to AdGuardHome. Just like HTTPS only. @ainar-g

fernvenue commented 1 year ago

So what about CNAMEs? What if the application require and only requests A but the domain also has AAAA results? I think it should be the behavior of the system and application itself, and AdGuardHome should do its own thing, just as I said https://github.com/AdguardTeam/AdGuardHome/discussions/4482#discussioncomment-2551212 here.

By the way, as @ainar-g said above:

Whether to use AAAA results or the A ones is usually up to DNS clients.

That's exactly what I meant.

57382 commented 1 year ago

So what about CNAMEs? What if the application require and only requests A but the domain also has AAAA results? I think it should be the behavior of the system and application itself, and AdGuardHome should do its own thing, just as I said #4482 (comment) here.

By the way, as @ainar-g said above:

Whether to use AAAA results or the A ones is usually up to DNS clients.

That's exactly what I meant.

The client application should serve me from start to finish. The DNS client app is usually alive, but if he's killing himself, I'll stop it! And you will silently watch him die. This is what makes us different.

I can't watch stupid things happen. You seem to be able to.

There is nothing special about CNAME. Use blacklists and whitelists to rule out any problematic domains. CNAME is in it. So CNAME won't break anything.

AdGuardHome has done a lot. Is DNSCrypt V2 support something an ad filter should do? no way. What about speed testing against resolved IP? AdGuardHome has already done it. It seems like this IP speed test feature should be removed, prompting AdGuardHome to grow into a pure ad filter. you're right.

Being able to speed boost the network makes AdGuardHome more competitive among its peers.

ainar-g commented 1 year ago

Please keep discussions about the future to the Discussions section. We'd like to keep the Issues section on-topic.

badgv commented 5 months ago

This is a very good suggestion. Just like mosdns, dual-stack domain names can only return IPV4/IPV6, but it does not affect pure IPV4/IPV6 domain names.