Unbound DNS switcher script
This commit is contained in:
18
UnboundUnbound
Executable file
18
UnboundUnbound
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
#Simple script to use standard DNS if Unbound (behind Adguard) is unavailable for some reason
|
||||
if [[ -z $1 ]]; then
|
||||
SECONDS=60
|
||||
# ^ If nothing is specified, wait 60 seconds
|
||||
else
|
||||
SECONDS=$1
|
||||
# ^ If specified, wait however many seconds user specifies
|
||||
fi
|
||||
sleep $SECONDS
|
||||
if ! nc -vz localhost 53 >/dev/null 2>&1; then
|
||||
# ^ If you cannot connect to DNS port on local host
|
||||
sed -i -e 's/192.168.0.66/1.1.1.1/g' /etc/resolv.conf
|
||||
# ^ replace local address with 1.1.1.1 (Cloudflare DNS)
|
||||
else
|
||||
sed -i -e 's/1.1.1.1/192.168.0.66/g' /etc/resolv.conf
|
||||
# ^ If connection is established, use local DNS
|
||||
fi
|
||||
Reference in New Issue
Block a user