Dnsmasq fails to forward requests to DHCP-set DNS server

My device (Itus Network Shield - not officially supported) has 3 ports. eth0 is the WAN, and solicits DHCP from upstream without issues.

eth1/eth2 are the LAN side and bridged on br-lan (10.10.10.10). dnsmasq handles DNS and DHCP for br-lan.

If I set dhcp.@dnsmasq[0].server='1.1.1.1' it works. if I set it as dhcp.@dnsmasq[0].server='192.168.1.1' (my edge router), or even dhcp.@dnsmasq[0].server='192.168.5.2' (my internal stub DNS), it works. If I remove the line, I have IP connectivity but no DNS resolution (duh).

I need dnsmasq to set the DNS server supplied by the DHCP upstream as the forwarding-to server automatically. I'm sure I'm missing a step/setting somewhere, but I can't seem to get it sorted.

Any suggestions?

What is the output of:

uci export network; uci export dhcp; \
ip -4 addr ; ip -4 ro li tab all ; ip -4 ru; \
ls -l  /etc/resolv.* /tmp/resolv.*; head -n -0 /etc/resolv.* /tmp/resolv.*
root@OpenWrt:/# uci export network; uci export dhcp; \
> ip -4 addr ; ip -4 ro li tab all ; ip -4 ru; \
> ls -l  /etc/resolv.* /tmp/resolv.*; head -n -0 /etc/resolv.* /tmp/resolv.*
package network

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

config globals 'globals'
        option ula_prefix 'fd18:0640:804c::/48'
        option packet_steering '1'

config interface 'lan'
        option type 'bridge'
        option ifname 'eth1 eth2'
        option proto 'static'
        option netmask '255.255.255.0'
        option ip6assign '60'
        option force_link '1'
        option ipaddr '10.10.10.10'

config interface 'wan'
        option ifname 'eth0'
        option proto 'dhcp'
        option hostname 'Shield'

config interface 'wan6'
        option ifname 'eth0'
        option proto 'dhcpv6'

config interface 'wg0'
        option proto 'wireguard'
        option private_key 'UHtpGhFuuCy+wK9R3gOhmNpmjr+bMeaQd2SjShYA+G0='
        option listen_port '51820'
        list addresses '192.168.9.1/24'
        list addresses 'fdf1:7610:d152:3a9c::1/64'

config wireguard_wg0 'wgclient'
        option public_key 'pl9U1p6pE8AByzu7GZ6CapZnY8pR3FYFsJxwkShzXiA='
        option preshared_key '70QpQkMj4S+jBqekegU5+1nUI6Qz5DCTsUJehfoRI2Y='
        list allowed_ips '192.168.9.0/24'
        list allowed_ips 'fdf1:7610:d152:3a9c::1/64'

package dhcp

config dnsmasq
        option localise_queries '1'
        option local '/lan/'
        option expandhosts '1'
        option authoritative '1'
        option readethers '1'
        option leasefile '/tmp/dhcp.leases'
        option localservice '1'
        option resolvfile '/tmp/resolv.conf.auto'
        option confdir '/tmp/dnsmasq.d'
        option port '53'
        option logqueries '1'
        option boguspriv '0'
        option domain 'tlan'
        list server '192.168.1.1'
        option rebind_protection '0'

config dhcp 'lan'
        option interface 'lan'
        option start '100'
        option limit '150'
        option leasetime '12h'
        option dhcpv6 'server'
        option ra 'server'
        option ra_slaac '1'
        option ra_management '1'
        option forced_link '1'

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

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

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    inet 192.168.1.126/24 brd 192.168.1.255 scope global eth0
       valid_lft forever preferred_lft forever
14: br-lan: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    inet 10.10.10.10/24 brd 10.10.10.255 scope global br-lan
       valid_lft forever preferred_lft forever
15: wg0: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1420 qdisc noqueue state UNKNOWN group default qlen 1000
    inet 192.168.9.1/24 brd 192.168.9.255 scope global wg0
       valid_lft forever preferred_lft forever
default via 192.168.1.1 dev eth0 proto static src 192.168.1.126 
10.10.10.0/24 dev br-lan proto kernel scope link src 10.10.10.10 
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.126 
192.168.9.0/24 dev wg0 proto kernel scope link src 192.168.9.1 
broadcast 10.10.10.0 dev br-lan table local proto kernel scope link src 10.10.10.10 
local 10.10.10.10 dev br-lan table local proto kernel scope host src 10.10.10.10 
broadcast 10.10.10.255 dev br-lan table local proto kernel scope link src 10.10.10.10 
broadcast 127.0.0.0 dev lo table local proto kernel scope link src 127.0.0.1 
local 127.0.0.0/8 dev lo table local proto kernel scope host src 127.0.0.1 
local 127.0.0.1 dev lo table local proto kernel scope host src 127.0.0.1 
broadcast 127.255.255.255 dev lo table local proto kernel scope link src 127.0.0.1 
broadcast 192.168.1.0 dev eth0 table local proto kernel scope link src 192.168.1.126 
local 192.168.1.126 dev eth0 table local proto kernel scope host src 192.168.1.126 
broadcast 192.168.1.255 dev eth0 table local proto kernel scope link src 192.168.1.126 
broadcast 192.168.9.0 dev wg0 table local proto kernel scope link src 192.168.9.1 
local 192.168.9.1 dev wg0 table local proto kernel scope host src 192.168.9.1 
broadcast 192.168.9.255 dev wg0 table local proto kernel scope link src 192.168.9.1 
0:      from all lookup local
32766:  from all lookup main
32767:  from all lookup default
lrwxrwxrwx    1 root     root            16 Jan  1  1970 /etc/resolv.conf -> /tmp/resolv.conf
lrwxrwxrwx    1 root     root            35 May 21 06:42 /tmp/resolv.conf -> /tmp/resolv.conf.d/resolv.conf.auto
-rw-r--r--    1 root     root             0 May 21 06:42 /tmp/resolv.conf.auto

/tmp/resolv.conf.d:
total 4
-rw-r--r--    1 root     root            96 May 21 06:59 resolv.conf.auto
==> /etc/resolv.conf <==
# Interface wan
nameserver 192.168.1.1
search lan
# Interface wan6
nameserver fd68:ac21:57a2::1

==> /tmp/resolv.conf <==
# Interface wan
nameserver 192.168.1.1
search lan
# Interface wan6
nameserver fd68:ac21:57a2::1

==> /tmp/resolv.conf.auto <==

==> /tmp/resolv.conf.d <==
head: /tmp/resolv.conf.d: I/O error

Keep in mind that I am having to put the line dhcp.@dnsmasq[0].server='192.168.1.1'
in order to get it to forward.. If I remove dhcp.@dnsmasq[0].server, resolution fails.

Time to change the WG key :smiley:

This:

is empty:

-rw-r--r--    1 root     root             0 May 21 06:42 /tmp/resolv.conf.auto

Change it to /tmp/resolv.conf.d/resolv.conf.auto

That seems to have done it.. Thank you!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.