Skip to content

Instantly share code, notes, and snippets.

@frafra
Last active October 22, 2019 20:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frafra/a1ca3d5eff81e6c6aebd8fab12b00695 to your computer and use it in GitHub Desktop.
Save frafra/a1ca3d5eff81e6c6aebd8fab12b00695 to your computer and use it in GitHub Desktop.
Enable/Disable DNS-over-TLS on Fedora
#!/bin/bash
# mkdir -p $HOME/bin && cd $_ && wget https://gist.githubusercontent.com/frafra/a1ca3d5eff81e6c6aebd8fab12b00695/raw/stubby-onoff.sh -O stubby-onoff && chmod +x $_ && cd -
set -ex
[ $USER == "root" ] || exec sudo $0
pkgs="getdns-stubby crudini"
rpm -q $pkgs || dnf install -y $pkgs
conf=/etc/NetworkManager/NetworkManager.conf
cp $conf $conf.bak
systemctl stop NetworkManager
if [ "$(crudini --get $conf main dns)" == "none" ]
then
echo "Disable stubby"
crudini --del $conf main dns
systemctl stop stubby
systemctl disable stubby
else
echo "Enable stubby"
crudini --set $conf main dns none
systemctl start stubby
systemctl enable stubby
echo -e 'nameserver 127.0.0.1\nnameserver ::1' > /etc/resolv.conf
fi
systemctl start NetworkManager
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment