GNU nano 4.9.2 /jffs/scripts/dnsmasq.postconf
#!/bin/sh
. /opt/share/diversion/file/post-conf.div # Added by Diversion
sh /jffs/addons/unbound/unbound.postconf "$1" # unbound_manager
#!/bin/sh
CONFIG=$1
source /usr/sbin/helper.sh
######################################################################
##### DO NOT EDIT THIS FILE MANUALLY #######
##### You are probably looking for #######
##### your customising script #######
##### '/opt/share/unbound/configs/unbound.postconf' #######
######################################################################
logger -t "(dnsmasq.postconf)" "Updating $CONFIG for unbound....." # unbound_manager
ROUTER="$(nvram get lan_ipaddr_rt)"
if [ -n "$(pidof unbound)" ];then
if [ -n "$(grep -E "^port: 53535" /opt/var/lib/unbound/unbound.conf)" ];then # Forward dnsmasq DNS requests to unbound
pc_delete "servers-file" $CONFIG
# By design, if GUI DNSSEC ENABLED then attempt to modify 'cache-size=0' results in dnsmasq start-up fail loop
# dnsmasq[15203]: cannot reduce cache size from default when DNSSEC enabled
# dnsmasq[15203]: FAILED to start up
if [ -n "$(grep "^dnssec" $CONFIG)" ];then
pc_delete "dnssec" $CONFIG
logger -t "(dnsmasq.postconf)" "**Warning: Removing 'dnssec' directive from 'dnsmasq' to allow DISABLE cache (set 'cache-size=0')"
fi
pc_replace "cache-size=1500" "cache-size=0" $CONFIG
UNBOUNDLISTENADDR="127.0.0.1#53535"
#UNBOUNDLISTENADDR="$(netstat -nlup | awk '/unbound/ { print $4 } ' | tr ':' '#')" # unbound_manager
pc_append "server=$UNBOUNDLISTENADDR" $CONFIG
if [ "$(uname -o)" == "ASUSWRT-Merlin-LTS" ];then # Requested by @dave14305
pc_delete "resolv-file" $CONFIG
pc_append "no-resolv" $CONFIG
fi
else
logger -t "(dnsmasq.postconf)" "dnsmasq DNS bypassed. unbound will be the primary DNS for ALL LAN Clients."
[ -z "$(grep -F "port=0" $CONFIG)" ] && pc_append "port=0" $CONFIG # Disable dnsmasq DNS resolver function
[ -z "$(grep -F "dhcp-option=lan,6,$ROUTER" $CONFIG)" ] && pc_append "dhcp-option=lan,6,$ROUTER" $CONFIG
pc_delete "servers-file" $CONFIG
pc_delete "no-negcache" $CONFIG
pc_delete "domain-needed" $CONFIG
pc_replace "cache-size=1500" "cache-size=0" $CONFIG
fi
else
sed -i '/port=0/d' $CONFIG
#!/bin/sh
. /opt/share/diversion/file/post-conf.div # Added by Diversion
sh /jffs/addons/unbound/unbound.postconf "$1" # unbound_manager
#!/bin/sh
CONFIG=$1
source /usr/sbin/helper.sh
######################################################################
##### DO NOT EDIT THIS FILE MANUALLY #######
##### You are probably looking for #######
##### your customising script #######
##### '/opt/share/unbound/configs/unbound.postconf' #######
######################################################################
logger -t "(dnsmasq.postconf)" "Updating $CONFIG for unbound....." # unbound_manager
ROUTER="$(nvram get lan_ipaddr_rt)"
if [ -n "$(pidof unbound)" ];then
if [ -n "$(grep -E "^port: 53535" /opt/var/lib/unbound/unbound.conf)" ];then # Forward dnsmasq DNS requests to unbound
pc_delete "servers-file" $CONFIG
# By design, if GUI DNSSEC ENABLED then attempt to modify 'cache-size=0' results in dnsmasq start-up fail loop
# dnsmasq[15203]: cannot reduce cache size from default when DNSSEC enabled
# dnsmasq[15203]: FAILED to start up
if [ -n "$(grep "^dnssec" $CONFIG)" ];then
pc_delete "dnssec" $CONFIG
logger -t "(dnsmasq.postconf)" "**Warning: Removing 'dnssec' directive from 'dnsmasq' to allow DISABLE cache (set 'cache-size=0')"
fi
pc_replace "cache-size=1500" "cache-size=0" $CONFIG
UNBOUNDLISTENADDR="127.0.0.1#53535"
#UNBOUNDLISTENADDR="$(netstat -nlup | awk '/unbound/ { print $4 } ' | tr ':' '#')" # unbound_manager
pc_append "server=$UNBOUNDLISTENADDR" $CONFIG
if [ "$(uname -o)" == "ASUSWRT-Merlin-LTS" ];then # Requested by @dave14305
pc_delete "resolv-file" $CONFIG
pc_append "no-resolv" $CONFIG
fi
else
logger -t "(dnsmasq.postconf)" "dnsmasq DNS bypassed. unbound will be the primary DNS for ALL LAN Clients."
[ -z "$(grep -F "port=0" $CONFIG)" ] && pc_append "port=0" $CONFIG # Disable dnsmasq DNS resolver function
[ -z "$(grep -F "dhcp-option=lan,6,$ROUTER" $CONFIG)" ] && pc_append "dhcp-option=lan,6,$ROUTER" $CONFIG
pc_delete "servers-file" $CONFIG
pc_delete "no-negcache" $CONFIG
pc_delete "domain-needed" $CONFIG
pc_replace "cache-size=1500" "cache-size=0" $CONFIG
fi
else
sed -i '/port=0/d' $CONFIG