-dnsmasq() {
- local cfg="$1"
- append_bool "$cfg" authoritative "--dhcp-authoritative"
- append_bool "$cfg" nodaemon "--no-daemon"
- append_bool "$cfg" domainneeded "--domain-needed"
- append_bool "$cfg" filterwin2k "--filterwin2k"
- append_bool "$cfg" nohosts "--no-hosts"
- append_bool "$cfg" nonegcache "--no-negcache"
- append_bool "$cfg" strictorder "--strict-order"
- append_bool "$cfg" logqueries "--log-queries=extra"
- append_bool "$cfg" noresolv "--no-resolv"
- append_bool "$cfg" localise_queries "--localise-queries"
- append_bool "$cfg" readethers "--read-ethers"
- append_bool "$cfg" dbus "--enable-dbus"
- append_bool "$cfg" boguspriv "--bogus-priv"
- append_bool "$cfg" expandhosts "--expand-hosts"
- config_get tftp_root "$cfg" "tftp_root"
- [ -d "$tftp_root" ] && append_bool "$cfg" enable_tftp "--enable-tftp"
- append_bool "$cfg" tftp_no_fail "--tftp-no-fail"
- append_bool "$cfg" nonwildcard "--bind-dynamic"
- append_bool "$cfg" fqdn "--dhcp-fqdn"
- append_bool "$cfg" proxydnssec "--proxy-dnssec"
- append_bool "$cfg" localservice "--local-service"
- append_bool "$cfg" quietdhcp "--quiet-dhcp"
- append_bool "$cfg" sequential_ip "--dhcp-sequential-ip"
- append_bool "$cfg" allservers "--all-servers"
- append_bool "$cfg" noping "--no-ping"
-
- append_parm "$cfg" dhcpscript "--dhcp-script"
- append_parm "$cfg" cachesize "--cache-size"
- append_parm "$cfg" dnsforwardmax "--dns-forward-max"
- append_parm "$cfg" port "--port"
- append_parm "$cfg" ednspacket_max "--edns-packet-max"
- append_parm "$cfg" dhcpleasemax "--dhcp-lease-max"
- append_parm "$cfg" "queryport" "--query-port"
- append_parm "$cfg" "minport" "--min-port"
- append_parm "$cfg" "domain" "--domain"
- append_parm "$cfg" "local" "--server"
- config_list_foreach "$cfg" "server" append_server
- config_list_foreach "$cfg" "address" append_address
- config_list_foreach "$cfg" "ipset" append_ipset
- config_list_foreach "$cfg" "interface" append_interface
- config_list_foreach "$cfg" "notinterface" append_notinterface
- config_list_foreach "$cfg" "addnhosts" append_addnhosts
- config_list_foreach "$cfg" "bogusnxdomain" append_bogusnxdomain
- append_parm "$cfg" "leasefile" "--dhcp-leasefile"
- append_parm "$cfg" "resolvfile" "--resolv-file"
- append_parm "$cfg" "serversfile" "--servers-file"
- append_parm "$cfg" "tftp_root" "--tftp-root"
- append_parm "$cfg" "dhcp_boot" "--dhcp-boot"
- append_parm "$cfg" "local_ttl" "--local-ttl"
- append_parm "$cfg" "pxe_prompt" "--pxe-prompt"
- config_list_foreach "$cfg" "pxe_service" append_pxe_service
- config_get DOMAIN "$cfg" domain
-
- config_get_bool ADD_LOCAL_DOMAIN "$cfg" add_local_domain 1
- config_get_bool ADD_LOCAL_HOSTNAME "$cfg" add_local_hostname 1
-
- config_get_bool readethers "$cfg" readethers
- [ "$readethers" = "1" -a \! -e "/etc/ethers" ] && touch /etc/ethers
-
- config_get leasefile $cfg leasefile
- [ -n "$leasefile" -a \! -e "$leasefile" ] && touch "$leasefile"
- config_get_bool cachelocal "$cfg" cachelocal 1
-
- config_get hostsfile "$cfg" dhcphostsfile
- [ -e "$hostsfile" ] && xappend "--dhcp-hostsfile=$hostsfile"
-
- local rebind
- config_get_bool rebind "$cfg" rebind_protection 1
- [ $rebind -gt 0 ] && {
- log_once \
- "DNS rebinding protection is active," \
- "will discard upstream RFC1918 responses!"
- xappend "--stop-dns-rebind"
-
- local rebind_localhost
- config_get_bool rebind_localhost "$cfg" rebind_localhost 0
- [ $rebind_localhost -gt 0 ] && {
- log_once "Allowing 127.0.0.0/8 responses"
- xappend "--rebind-localhost-ok"
- }
-
- append_rebind_domain() {
- log_once "Allowing RFC1918 responses for domain $1"
- xappend "--rebind-domain-ok=$1"
- }
-
- config_list_foreach "$cfg" rebind_domain append_rebind_domain
- }
-
- config_get_bool dnssec "$cfg" dnssec 0
- [ "$dnssec" -gt 0 ] && {
- xappend "--conf-file=$TRUSTANCHORSFILE"
- xappend "--dnssec"
- xappend "--dnssec-timestamp=$TIMESTAMPFILE"
- append_bool "$cfg" dnsseccheckunsigned "--dnssec-check-unsigned"
- }
-
- dhcp_option_add "$cfg" "" 0
-
- xappend "--dhcp-broadcast=tag:needs-broadcast"
-
- mkdir -p /tmp/hosts /tmp/dnsmasq.d
- xappend "--addn-hosts=/tmp/hosts"
- xappend "--conf-dir=/tmp/dnsmasq.d"