DNS query returns IPv6 address incorrectly

I have multiple dnsmasq sections in my host configuration, one for my wired lan and one for my WiFi network. These serve address for two different VLAN interfaces.

For a few of my hosts I have two static leases defined, one for "lan" and one for "wifi".
The DHCP and DHCPv6 all work correctly. Both interfaces get the correct IPv4 and IPv6 address.

The problem is with DNS. If I query for the WiFi address I just get the (correct) IPv4 address, but if I query for the LAN address I get the (correct) IPv4 address but both the lan and wifi IPv6 addresses:

>host carnepie.wifi
carnepie.wifi has address 10.3.142.4

> host carnepie.lan 
carnepie.lan has address 10.3.141.4
carnepie.lan has IPv6 address 2600:4040:f107:ed20::cf7
carnepie.lan has IPv6 address fdc9:168:e6b2:10::cf7
carnepie.lan has IPv6 address fdc9:168:e6b2:20::cf7
carnepie.lan has IPv6 address 2600:4040:f107:ed10::cf7

In the above example the IPv6 addresses ending in "20::cf7" are actually assigned to the wifi interface, so should be returned with the .wifi query and not the .lan query.

The problem seems to be that the DNS server gets the IPv6 addresses from /tmp/hosts/odhcpd, but is not smart enough to match the interface name with the correct DNS suffix.

Is there some configuration option I may need to fix?

Here are the relevant parts of my /etc/config/dhcp file:

/etc/config/dhcp - dnsmasq

config dnsmasq 'lan_dns'
option rebind_protection '1'
option rebind_localhost '1'
option local '/lan/'
option domain 'lan'
option expandhosts '1'
option authoritative '1'
option leasefile '/tmp/dhcp.lan.leases'
option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
list interface 'lan'
list notinterface 'loopback'
option localservice '0'
option nonegcache '1'

config dnsmasq 'wifi_dns'
option domainneeded '1'
option localise_queries '1'
option rebind_protection '1'
option rebind_localhost '1'
option local '/wifi/'
option domain 'wifi'
option expandhosts '1'
option authoritative '1'
option leasefile '/tmp/dhcp.wifi.leases'
option resolvfile '/tmp/resolv.conf.d/resolv.conf.auto'
list interface 'wifi'
list notinterface 'loopback'
option localservice '0'

/etc/config/dhcp - dhcp

config dhcp 'lan'
option interface 'lan'
option instance 'lan_dns'
option start '200'
option limit '40'
option leasetime '2h'
option dhcpv6 'server'
option ra 'server'
list ra_flags 'managed-config'
list ra_flags 'other-config'

config dhcp 'wifi'
option interface 'wifi'
option instance 'wifi_dns'
option start '200'
option limit '50'
option leasetime '2h'
option dhcpv6 'server'
option ra 'server'
list ra_flags 'managed-config'
list ra_flags 'other-config'

etc/config/dhcp - host

config host
option name 'carnepie'
option mac 'D8:3A:DD:B8:A2:D7'
option instance 'lan_dns'
option ip '10.3.141.4'
option dns '1'

config host
option name 'carnepie'
option mac 'd8:3a:dd:b8:a2:d8'
option instance 'wifi_dns'
option ip '10.3.142.4'
option dns '1'

This is because dnsmasq only handles DHCPv4 and DNS service. In OpenWrt, DHCPv6 is handled by odhcpd. When odhcpd hands out a lease, it writes the hostname and its IPv6 address to /tmp/hosts/odhcpd (as you've already seen) and sends a signal to dnsmasq to read the new addresses. Since odhcpd doesn't know about your wifi domain, it all gets lumped into the lan domain.

Please also post the contents of /etc/config/network so we have a clearer picture of your VLAN setup.

1 Like