aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README14
-rw-r--r--UNLICENSE24
-rwxr-xr-xchdns.sh53
3 files changed, 91 insertions, 0 deletions
diff --git a/README b/README
new file mode 100644
index 0000000..8736527
--- /dev/null
+++ b/README
@@ -0,0 +1,14 @@
+chdns - Change DNS
+==================
+!) Forked from https://github.com/SeydEf/DNS_changer
+Simple POSIX shell script to change the dns for your active connection
+using NetworkManager(nmcli).
+
+Requirements
+------------
+- POSIX compliant shell(Dash)
+- NetworkManager
+
+Default Servers
+---------------
+Quad9, CloudFlare, Google
diff --git a/UNLICENSE b/UNLICENSE
new file mode 100644
index 0000000..68a49da
--- /dev/null
+++ b/UNLICENSE
@@ -0,0 +1,24 @@
+This is free and unencumbered software released into the public domain.
+
+Anyone is free to copy, modify, publish, use, compile, sell, or
+distribute this software, either in source code form or as a compiled
+binary, for any purpose, commercial or non-commercial, and by any
+means.
+
+In jurisdictions that recognize copyright laws, the author or authors
+of this software dedicate any and all copyright interest in the
+software to the public domain. We make this dedication for the benefit
+of the public at large and to the detriment of our heirs and
+successors. We intend this dedication to be an overt act of
+relinquishment in perpetuity of all present and future rights to this
+software under copyright law.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+For more information, please refer to <http://unlicense.org/>
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"
+