add --dns-nocache option

This commit is contained in:
garywill 2022-04-03 18:03:51 +08:00
parent e8284c5398
commit 433b3b8d39
2 changed files with 20 additions and 9 deletions

View File

@ -317,6 +317,7 @@ Options:
-d DNS server will take into account /etc/hosts -d DNS server will take into account /etc/hosts
-e <hosts_file> DNS server will take into account additional -e <hosts_file> DNS server will take into account additional
hosts file hosts file
--dns-nocache DNS server no cache
--mac <MAC> Set MAC address --mac <MAC> Set MAC address
--random-mac Use random MAC address --random-mac Use random MAC address

View File

@ -67,6 +67,7 @@ Options:
-d DNS server will take into account /etc/hosts -d DNS server will take into account /etc/hosts
-e <hosts_file> DNS server will take into account additional -e <hosts_file> DNS server will take into account additional
hosts file hosts file
--dns-nocache DNS server no cache
--mac <MAC> Set MAC address --mac <MAC> Set MAC address
--random-mac Use random MAC address --random-mac Use random MAC address
@ -156,6 +157,7 @@ define_global_variables(){
SHOW_DNS_QUERY=0 # log dns SHOW_DNS_QUERY=0 # log dns
ETC_HOSTS=0 ETC_HOSTS=0
ADDN_HOSTS= ADDN_HOSTS=
DNS_NOCACHE=
CONN_IFACE= # which interface user choose to use to create network CONN_IFACE= # which interface user choose to use to create network
INTERNET_IFACE= # which interface to get Internet from INTERNET_IFACE= # which interface to get Internet from
THISHOSTNAME= # this host's name the DNS tells clients THISHOSTNAME= # this host's name the DNS tells clients
@ -322,6 +324,10 @@ parse_user_options(){
ADDN_HOSTS="$1" ADDN_HOSTS="$1"
shift shift
;; ;;
--dns-nocache)
shift
DNS_NOCACHE=1
;;
--isolate-clients) --isolate-clients)
shift shift
@ -1822,6 +1828,10 @@ write_dnsmasq_conf() {
no-poll no-poll
EOF EOF
fi fi
if [[ $DNS_NOCACHE -eq 1 ]]; then
echo "cache-size=0" >> "$CONFDIR/dnsmasq.conf"
echo "no-negcache" >> "$CONFDIR/dnsmasq.conf"
fi
if [[ $IPV6 -eq 1 ]];then if [[ $IPV6 -eq 1 ]];then
cat <<- EOF >> "$CONFDIR/dnsmasq.conf" cat <<- EOF >> "$CONFDIR/dnsmasq.conf"
listen-address=${GATEWAY6} listen-address=${GATEWAY6}