Advertising external DNS server for DHCP clients

Hello, whatever I do OpenWrt does not advertise my DNS server (a Pi-hole actually) for DHCP clients. Here is my /etc/config/dhcp

config dnsmasq
        option readethers '1'
        option leasefile '/tmp/dhcp.leases'
        option domain 'local'
        option local 'local'
        option logqueries '1'
        option sequential_ip '1'
        option localservice '0'
        option boguspriv '0'
        option authoritative '1'
        option nonwildcard '1'
        option rebind_protection '1'
        list interface 'lan0'
        option allservers '1'
        list server ''
        list server 'fd31:8ee3:937c:1:ba27:ebff:fe20:51a3'

config dhcp 'lan'
        option interface 'lan'
        option ra_slaac '1'
        list ra_flags 'managed-config'
        list ra_flags 'other-config'
        option force '1'
        option dhcpv4 'server'
        option start '10'
        option leasetime '24h'
        option limit '240'
        option ra 'server'
        option ra_default '1'
        list dhcp_option '6,'

config dhcp 'wan'
        option interface 'wan'
        option ignore '1'

config odhcpd 'odhcpd'
        option leasefile '/tmp/hosts/odhcpd'
        option leasetrigger '/usr/sbin/odhcpd-update'
        option loglevel '4'
        option maindhcp '1'

And this is the /etc/config/network

config interface 'loopback'
        option ifname 'lo'
        option proto 'static'
        option ipaddr ''
        option netmask ''

config globals 'globals'
        option ula_prefix '*****************::/48'

config interface 'lan'
        option type 'bridge'
        option ifname 'eth1'
        option proto 'static'
        option netmask ''
        option force_link '0'
        option ipaddr ''
        option ip6assign '64'
        option ip6hint '1'
        list dns ''

config interface 'wan'
        option ifname 'eth0'
        option proto 'dhcp'
        option peerdns '0'

config interface 'WAN6'
        option ifname 'eth0'
        option proto '6in4'
        option username '********************'
        option peeraddr '**************************'
        option password '*****************'
        option tunnelid '************'
        list ip6prefix '*******************::/64'
        option ipaddr '*******************'
        option ip6addr '****************************::2/64'
        option mtu '1480'

I am a bit confused about the multiple locations for setting DNS. Should I use dhcp-opkg instead? My goal is to give IP address for clients on the LAN and tell them to use as DNS server.
Whatever I do they use the LAN IP address as DNS server.
I alredy tried rebooting the OpenWRT and rebooting the clients, but no avail.

Thanks for any advice.

This is the correct option for advertising a different dns.
You have given a quite high leasetime of 24 hours and maybe the dhcp clients didn't request again dhcp settings.
If the problem persists, install tcpdump and run the following command:
tcpdump -i eth1 -vn udp port 67
force a client to request dhcp settings, let it get some logs, stop capturing with Ctrl-c, copy and paste it here in preformatted text (the </> button).

1 Like

I restored from backup as a last resort :slightly_smiling_face:

The differences are:


config dhcp 'lan'
   list dns ''

config interface 'lan'
   list dns ''     <<<<< probably does not matter
   list dns ''     <<<<< probably does not matter

config interface 'wan'
   list dns ''

Now my DHCP clients get my pi-hole ( as DNS server.

These must be vice versa.
Although you should omit the GoogleDNS and only use Pihole.