diff options
Diffstat (limited to 'chdns.sh')
-rwxr-xr-x | chdns.sh | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/chdns.sh b/chdns.sh new file mode 100755 index 0000000..2d9a85a --- /dev/null +++ b/chdns.sh @@ -0,0 +1,53 @@ +#!/usr/bin/sh + +dns_names=" + Default + Quad9 + Google + CloudFlare +" +dns_ips=" + 0 + 9.9.9.9,149.112.112.112 + 8.8.8.8,8.8.4.4 + 1.1.1.1,1.0.0.1 +" + +ssid=$(nmcli -t -f NAME connection show --active | sed q1) +default_dns=$(nmcli -g ipv4.dns connection show $ssid) + +echo "Connection name: $ssid" +if [ -z $default_dns ]; then + echo "DNS is not set!" +else + echo "DNS set: $default_dns" +fi +echo + +ind=0 +for dns in $dns_names; do + echo ${ind}. $dns + ind=$((ind+1)) +done + +echo -n "enter the index: " +read ind +if [ $ind = 0 ]; then + echo "nothing changed" + exit +fi +ind=$((ind+1)) + +dns_name=$(echo $dns_names | cut -d ' ' -f$ind) +dns_ip=$(echo $dns_ips | cut -d ' ' -f$ind) + +echo +echo "you selected: $dns_name" +echo "dns ips: $dns_ip" +echo + +nmcli connection modify $ssid ipv4.dns $dns_ip +nmcli connection down $ssid > /dev/null +nmcli connection up $ssid > /dev/null +echo "dns changed successfully" + |