Created
November 15, 2023 00:34
-
-
Save naranyala/26ba8b23fc38d90e2f092f3f64a1a9a8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Prompt the user to choose a DNS server | |
echo "Choose a DNS server:" | |
echo "1. Cloudflare (1.1.1.1)" | |
echo "2. Google (8.8.8.8)" | |
read -p "Enter your choice (1 or 2): " choice | |
# Set the DNS server based on user's choice | |
case $choice in | |
1) | |
DNS_SERVER="1.1.1.1" | |
;; | |
2) | |
DNS_SERVER="8.8.8.8" | |
;; | |
*) | |
echo "Invalid choice. Exiting." | |
exit 1 | |
;; | |
esac | |
# Backup the current resolv.conf file | |
cp /etc/resolv.conf /etc/resolv.conf.bak | |
# Create a new resolv.conf file with the chosen DNS server | |
echo "nameserver $DNS_SERVER" | sudo tee /etc/resolv.conf >/dev/null | |
# Display a message indicating the change | |
echo "Default DNS changed to $DNS_SERVER" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment