AdguardTeam / AdGuardHome

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

OpenWRT: AdGuard Home as a dnsmasq replacement #1464

Open ameshkov opened 4 years ago

ameshkov commented 4 years ago

We should provide an easy way to replace dnsmasq on openwrt: https://openwrt.org/docs/guide-user/base-system/dhcp.dnsmasq

So we should provide an option to import the necessary configuration parameters including DHCP settings and DNS settings. Please note, that the DNS server from there will be used as a bootstrap, the real upstream will be configured in AdGuard Home settings exclusively.

Additionally, we should figure out how to keep DHCP integration in place. How does openwrt read the information about dynamic DHCP leases?

szolin commented 4 years ago

The absolute minimum is:

cat /etc/config/network

config interface 'lan'
        option netmask '255.255.255.0'
        option ipaddr '192.168.8.1'

cat /etc/config/dhcp

config dhcp 'lan'
        option start '100'
        option limit '150'
        option leasetime '12h'

ignoring anything else.

And DNS server bootstrap address must be read from /etc/resolv.conf:

nameserver ...
nameserver ...
ameshkov commented 4 years ago

Don't forget about static leases

youri-- commented 4 years ago

And dhcp-option. I currently have these in /etc/dnsmasq.conf:

dhcp-option=60,IPTV_RG dhcp-option=28,192.168.1.255

I need these for my IPTV to function.

ameshkov commented 4 years ago

Reassigning to v0.103, a lot about our DHCP server should be improved first

mercyground commented 2 years ago

OpenWrt updated to 107 release and it is now easier to swap dnsmasq to ptr/rdns only and use AGH as primary dns.

https://openwrt.org/docs/guide-user/services/dns/adguard-home has more info.

I updated instructions to manually install AGH on OpenWrt and detail all the issues and fixes. https://forum.openwrt.org/t/how-to-updated-2021-installing-adguardhome-on-openwrt/113904

At present I wouldn't use AGH DHCP except on simple networks. As was mentioned earlier your DHCP needs work to do more than simple networks. A few people have had issues with multiple IP ranges and VLANS.

The compromise of using OpenWrt for dhcp and AGH for DNS seems to be best fix at present. (edit) - NTP really also requires a DNS exception to avoid issues getting/setting date/time so encrypted DNS can be used. https://openwrt.org/docs/guide-user/services/dns/adguard-home#bypassing_encrypted_dns_for_ntp

sergey-brutsky commented 2 years ago

Hey @ameshkov,

Could you please clarify how to configure AdGuardHome on openwrt properly in case I use pppoe as a wan connection where upstream DNS servers are dynamically advertised by provider ?

The problem is that they are dynamic and can be changed once you reconnected. Does AdGuardHome respects file /tmp/resolve.conf.auto where providers DNS are configured ?

Thanks

hgl commented 7 months ago

@mercyground I want to give the recommended approach a try, but doesn't it make local devices' hostnames unresolvable, since dnsmasq is still the DHCP server and Adguard home doesn't know about these devices?

quyenvsp commented 1 month ago

Update: Oh my bad, if want use dnsmasq just change dns to port 54 then all will work.

Hi, after move dnsmasq to port 54 and change adguardhome port 53 follow document, client on lan still can connect to internet but openwrt itself can not (can not ping google, can not opkg update) I have fixed it by set dns 8.8.8.8 for pppoe-wan interface (to edit /tmp/resolv.conf), openwrt itself now can connect to internet. But one more issue that OpenVPN server running on openwrt has this config

push "dhcp-option DNS 10.8.0.1"
push "dhcp-option DOMAIN lan"

It also stopped client connect to vpn access internet because dns 10.8.0.1 not work now. can fix it by change openvpn dhcp dns to 8.8.8.8, but I want openvpn client use my adguardhome dns as default!

Anyone have guide how to make it work without change dns to 8.8.8.8? Current I forced revert to use dnsmasq at port 53 for keep other things work.

Thank you.