openwrt / odhcpd

This repository is a mirror of https://git.openwrt.org/?p=project/odhcpd.git. Pull requests will be accepted which will be merged in odhcpd.git
GNU General Public License v2.0
160 stars 96 forks source link

odhcpd: (interface) DNS search domains are ignored #206

Open systemcrash opened 8 months ago

systemcrash commented 8 months ago

if I have e.g.

config interface 'lan'
    option device 'br-lan'
    option proto 'static'
    option ip6assign '64'
    list ip6class 'local'
    list ip6class 'wan6'
    list ipaddr '192.168.1.1/24'
    list dns_search 'jinglebollocks'

and I have DHCP config A e.g.

config dhcp 'lan'
    option interface 'lan'
    option start '100'
    option limit '150'
    option dhcpv4 'server'
    option leasetime '10m'
    option ra 'hybrid'
    option dhcpv6 'hybrid'
    option ra_default '1'
    option ndp 'relay'
    list ra_flags 'home-agent'
    option ra_mininterval '5'
    option ra_maxinterval '60'
    option preferred_lifetime '7m'

and later DHCP config B (as A but with domains) e.g.:

config dhcp 'lan'
...
    list domain 'congabonga'

The GUI in 23.05.0 says for Announced DNS domains that: If left unspecified, the local device DNS search domain will be announced.

The ICMPv6 RA do not contain DNSSL Option Type 31 with jinglebollocks. But if I set DHCP config B, ICMPv6 RA contain DNSSL Option Type 31 with congabonga:

ICMPv6 Option (DNS Search List Option congabonga)
    Type: DNS Search List Option (31)
    Length: 4 (32 bytes)
    Reserved
    Lifetime: 180
    Domain Names: congabonga
    Padding

Can anyone else verify if this behaviour is also present?

Which is correct: the described behaviour or actual?

ziqin commented 3 months ago

I met the same problem in 21.02.

I didn't add a network.lan.dns_search but set dhcp.@dnsmasq[0].domain instead. Hosts in LAN can obtain the DNS search list from DHCP(v4), but a wireshark capture of IPv6 traffic shows no DNS search list, neither in Router Advertisement nor DHCPv6 reply message. If I add a dhcp.lan.domain, the search domain will show up in both the RA and DHCPv6 reply.

I'd expect a DNS search list in both the RA and DHCPv6 reply if one of dhcp.lan.domain, network.lan.dns_search or dhcp.@dnsmasq[0].domain is configured. Should there be any conflict, a precedence rule (e.g., dhcp.lan.domain > network.lan.dns_search > dhcp.@dnsmasq[0].domain) may apply.

BTW, I can't see any difference between dhcp.lan.domain and network.lan.dns_search. Should we merge them?

matejvasek commented 1 week ago

I think I encountered similar issue: when I disable IPv4 on my laptop then domain is not set (checked via resolvectl). I had to set dhcp.lan.domain in /etc/config/dhcp manually.

Also does network.lan.dns_search have any effect on autoconf at all?

ziqin commented 1 week ago

I can't see any difference between dhcp.lan.domain and network.lan.dns_search.

After several trials and captures, I've come to realize the semantic difference between network.$interface.dsn_search and dhcp.$interface.domain.

network.$interface.dns_search represents the DNS domain search list received from upstream. Typically, a router who statically configures its WAN IP address could choose to statically configures network.wan.dns_search; if it receives its WAN IP and search list from DHCP, this configuration is usually unnecessary. When the OpenWrt device itself resolves a (non-FQDN) hostname, it is supposed to try network.wan.dns_search.

dhcp.$interface.domain is the domain search list to distribute to attached downstream hosts via DHCPv6 Option 24 and/or Router Advertisement Option 31. It is supposed to be configured on LAN interface(s). (FYI, a dhcp.lan.dhcp_option can be added to configure DHCP Option 119 for IPv4.)

dhcp.@dnsmasq[0].domain only sets DHCP Option 15 currently. It is also offered to downstream hosts via DHCP(v4).