diff options
| author | Paul Donald | 2024-03-26 23:43:41 +0000 |
|---|---|---|
| committer | Hauke Mehrtens | 2024-10-20 19:56:16 +0000 |
| commit | 7c501e0ed2e891069b9fa0eb35a378e2ac330a44 (patch) | |
| tree | 59032ea7568ad15f37fd36dc6f27976cb08ce1ee | |
| parent | 47ce5f7dd5bc67465d8dfcdec5d37f5fa71809af (diff) | |
| download | openwrt-7c501e0ed2e891069b9fa0eb35a378e2ac330a44.tar.gz | |
dnsmasq: add handling of `dns-rr` to init script (add arbitrary resource records)
Add support for handling of DNS RR (Resource Records) requests, which
are needed for the HTTPS Type 65 records, introduced to support the
DNS-based Service Discovery (DNS-SD) mechanism for HTTPS services and
defined in the RFC 9460 (9.1. Query Names for HTTPS RRs).
Ref: https://forum.openwrt.org/t/resolving-query-type-65-to-local-address-for-ios-clients-in-dnsmasq/179504/11
uci config usage:
config dnsrr
option rrname 'foo.example.com'
option rrnumber '65'
option hexdata '00'
hexdata is optional.
Available since dnsmasq 2.62 (for around 12 years at this point).
Note: dnsmasq dns-rr are not affected by filter-rr
Tested on 22.03.5
Signed-off-by: Paul Donald <newtwen+github@gmail.com>
Tested-by: Vladimir Kochkovski <ask@getvladimir.com>
Link: https://github.com/openwrt/openwrt/pull/14975
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
| -rwxr-xr-x | package/network/services/dnsmasq/files/dnsmasq.init | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/package/network/services/dnsmasq/files/dnsmasq.init b/package/network/services/dnsmasq/files/dnsmasq.init index cd1a16abc5..451cb674f8 100755 --- a/package/network/services/dnsmasq/files/dnsmasq.init +++ b/package/network/services/dnsmasq/files/dnsmasq.init @@ -788,6 +788,29 @@ dhcp_hostrecord_add() { xappend "--host-record=$record" } +dhcp_dnsrr_add() { + #This adds arbitrary resource record types (of IN class) whose optional data must be hex + local cfg="$1" + local rrname rrnumber hexdata + + config_get rrname "$cfg" rrname + [ -n "$rrname" ] || return 0 + + config_get rrnumber "$cfg" rrnumber + [ -n "$rrnumber" ] && [ "$rrnumber" -gt 0 ] || return 0 + + config_get hexdata "$cfg" hexdata + + # dnsmasq accepts colon XX:XX:.., space XX XX .., or contiguous XXXX.. hex forms or mixtures thereof + if [ -n "${hexdata//[0-9a-fA-F\:\ ]/}" ]; then + # is invalid hex literal + echo "dnsmasq: \"$hexdata\" is malformed hexadecimal (separate hex with colon, space or not at all)." >&2 + return 1 + fi + + xappend "--dns-rr=${rrname},${rrnumber}${hexdata:+,$hexdata}" +} + dhcp_relay_add() { local cfg="$1" local local_addr server_addr interface @@ -1161,6 +1184,7 @@ dnsmasq_start() config_foreach filter_dnsmasq match dhcp_match_add "$cfg" config_foreach filter_dnsmasq domain dhcp_domain_add "$cfg" config_foreach filter_dnsmasq hostrecord dhcp_hostrecord_add "$cfg" + config_foreach filter_dnsmasq dnsrr dhcp_dnsrr_add "$cfg" [ -n "$BOOT" ] || config_foreach filter_dnsmasq relay dhcp_relay_add "$cfg" echo >> "$CONFIGFILE_TMP" |