dnsmasq: add a new "bind" configuration option
authorRui Salvaterra <rsalvaterra@gmail.com>
Thu, 8 Jul 2021 10:33:07 +0000 (11:33 +0100)
committerJo-Philipp Wich <jo@mein.io>
Wed, 21 Feb 2024 21:31:36 +0000 (22:31 +0100)
The nonwildcard option only allows to choose between the default behaviour (bind
to the wildcard address only, which unfeasible when running multiple instances
of dnsmasq) and --bind-dynamic (bind to any existing/new interfaces which aren't
explicitly configured otherwise). Add a new "bind" option, which can take the
value of "dynamic" or "interfaces", allowing the user to additionally choose the
--bind-interfaces behaviour (bind only to explicitly configured interfaces).

The dnsmasq man page [1] contains more detailed information about these
arguments. Finally, the nonwildcard option is kept for backwards compatibility.

[1] https://thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html

Signed-off-by: Rui Salvaterra <rsalvaterra@gmail.com>
package/network/services/dnsmasq/files/dhcp.conf
package/network/services/dnsmasq/files/dnsmasq.init

index d5b9dfa018c146a0031920f75c4614f9b2681c4b..3ebae43486ff819dcf7d54241ae6c2c66784804a 100644 (file)
@@ -16,7 +16,7 @@ config dnsmasq
        option leasefile        '/tmp/dhcp.leases'
        option resolvfile       '/tmp/resolv.conf.d/resolv.conf.auto'
        #list server            '/mycompany.local/1.2.3.4'
-       option nonwildcard      1 # bind to & keep track of interfaces
+       option bind             'dynamic' # bind to & keep track of interfaces
        #list interface         br-lan
        #list notinterface      lo
        #list bogusnxdomain     '64.94.110.11'
index be701bf525cdae859c47dec6c6aec46b460b9d41..5b6d00042249b44379b5e4d83c628adaf4643011 100755 (executable)
@@ -958,7 +958,18 @@ dnsmasq_start()
        config_get tftp_root "$cfg" "tftp_root"
        [ -n "$tftp_root" ] && mkdir -p "$tftp_root" && append_bool "$cfg" enable_tftp "--enable-tftp"
        append_bool "$cfg" tftp_no_fail "--tftp-no-fail"
-       append_bool "$cfg" nonwildcard "--bind-dynamic" 1
+
+       config_get bind "$cfg" "bind"
+       case "$bind" in
+               dynamic|interfaces)
+                       xappend "--bind-$bind"
+                       ;;
+               "")
+                       # for compatibility reasons
+                       append_bool "$cfg" nonwildcard "--bind-dynamic" 1
+                       ;;
+       esac
+
        append_bool "$cfg" fqdn "--dhcp-fqdn"
        append_bool "$cfg" proxydnssec "--proxy-dnssec"
        append_bool "$cfg" localservice "--local-service"