Skip to content

Instantly share code, notes, and snippets.

@jonasjancarik
Last active April 22, 2022 18:36
Show Gist options
  • Save jonasjancarik/abf01acd5783162a99765ff226ef0b33 to your computer and use it in GitHub Desktop.
Save jonasjancarik/abf01acd5783162a99765ff226ef0b33 to your computer and use it in GitHub Desktop.
echo "Writing a script to toggle the settings (~/toggle_dns.sh)..."
if echo "#!/bin/bash
if grep -Fxq \"dns=none\" /etc/NetworkManager/NetworkManager.conf
then
echo \"[main]
plugins=ifupdown,keyfile
[ifupdown]
managed=false\" > /etc/NetworkManager/NetworkManager.conf
else
echo \"[main]
plugins=ifupdown,keyfile
dns=none
rc-manager=unmanaged
[ifupdown]
managed=false\" > /etc/NetworkManager/NetworkManager.conf
echo \"nameserver 8.8.8.8
nameserver 1.1.1.1
nameserver 8.8.4.4\" > /etc/resolv.conf
fi
systemctl restart NetworkManager" > ~/toggle_dns.sh
then
chmod +x ~/toggle_dns.sh
echo "Creating a desktop shortcut..."
if echo "[Desktop Entry]
Version=1.0
Type=Application
Name=Toggle auto DNS
Comment=
Exec=pkexec /home/$USER/toggle_dns.sh
Icon=
Path=
Terminal=true
StartupNotify=false" > ~/Desktop/Toggle\ auto\ DNS\.desktop
then
chmod +x ~/Desktop/Toggle\ auto\ DNS\.desktop
echo "
All done. There should be a new icon on the desktop which you can use to toggle between automatic and manual DNS settings. Or, e.g. if you are not using a GUI, you can run the script directly with ~/toggle_dns.sh."
else
echo "Coudln't create the shortcut"
fi
else
echo "Couldn't create the script."
fi
@jonasjancarik
Copy link
Author

jonasjancarik commented Apr 22, 2022

One-liner to install:

rm -rf ~/kali_toggle_auto_dns; git clone https://gist.github.com/abf01acd5783162a99765ff226ef0b33.git ~/kali_toggle_auto_dns && chmod +x ~/kali_toggle_auto_dns/kali_toggle_auto_dns.sh && ~/kali_toggle_auto_dns/kali_toggle_auto_dns.sh && rm -rf ~/kali_toggle_auto_dns

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment