mrrfv / cloudflare-gateway-pihole-scripts

Use Cloudflare Gateway DNS/VPN to block ads, malware and tracking domains - free alternative to NextDNS, Pi-hole and Adguard
MIT License
350 stars 989 forks source link

[OFF-TOPIC] [Need Help] How to use it in router which only supports IPv4 DNS? #91

Open webpixeldesign opened 7 months ago

webpixeldesign commented 7 months ago

I am using Xiaomi Router 3c & Router 4c, both of which only support IPv4 DNS. Cause when I entered the IPv6 one, it gave an error saying the DNS needs to of a value 255.255.255.255 max. The script is working perfectly fine. This is first time I used node.js, npm, etc. but surprisingly managed to do it in one go. Tried the output in two of my android devices and chrome browser using the dns over tls / https DNS and all are working fine.

I just couldn't manage to make it work in my router and windows 10 PC.

My ISP is using PPPoE connection type, which assigns random IP address to my network.

If someone can guide me how can I use this DNS with my router I'll be very grateful 🙏

mi3-wireless-router-repeater-mmode

webpixeldesign commented 7 months ago

Forgot to mention that, the DNS Cloudflare provided to be used in IPv4 devices, didn't work. I mean the internet was working fine, but nothing was getting filtered. I was getting ads in all my devices.

mrrfv commented 7 months ago

It's better to manually configure all your devices to use the DNS settings to benefit from DoH/DoT.

The DNS settings provided by Cloudflare might not've worked if you didn't link your IP address to the DNS location. This is required because we don't have an infinite amount of IPv4 addresses, so Cloudflare can't give everyone their personal IP for DNS. You can do this by clicking on the DNS location and pressing "Configure", then "Add IP" in the "Source IPv4 address" section. Keep in mind that this may eventually break if you have a dynamic IP.

As an ideal alternative that doesn't use moving parts, run a tiny DNS server at home that forwards queries over to your DoH URL such as cloudflared:

cloudflared proxy-dns --address 0.0.0.0 --upstream https://changeme.cloudflare-gateway.com/dns-query
galpt commented 4 months ago

@webpixeldesign

You can use IPv4 but you'll need a static IP address from your ISP, which most home ISPs don't give static IPs unless you specifically request it.

Go to your Cloudflare One dashboard > Gateway > DNS Locations and add your IPv4 there.

Screenshot 2024-07-08 100805

After that, Cloudflare will give you 2 IPv4 addresses that you can use on your router or anything that uses IPv4. To check if the DNS works, you open those IPv4 addresses on your browser and they should show you a block page of your Gateway.

Screenshot 2024-07-08 101147

This will only work after you've added your ISP's IP address there. I mentioned about getting a static IP because the IPv4 Gateway needs to check that you're the same IP accessing the Gateway. If static IP isn't possible, just use DoH since it's safer and less hassle.