Skip to content

Instantly share code, notes, and snippets.

@grenade
Last active November 5, 2023 11:29
Show Gist options
  • Save grenade/6ed317939eff8f5f7c400638e06c6885 to your computer and use it in GitHub Desktop.
Save grenade/6ed317939eff8f5f7c400638e06c6885 to your computer and use it in GitHub Desktop.
set all wifi connections to use cloudflare dns
(
IFS=$'\n'
for line in $(nmcli --fields UUID,TYPE,NAME connection show); do
conn_uuid=$(echo ${line} | cut -d ' ' -f 1)
conn_type=$(echo ${line} | cut -d ' ' -f 3)
conn_name=$(echo ${line} | cut -d ' ' -f 4- | xargs)
if [ "${conn_type}" = "wifi" ]; then
echo "name: $(tput bold)${conn_name}"
echo "$(tput dim)uuid: ${conn_uuid}, type: ${conn_type}"
nmcli connection modify ${conn_uuid} ipv4.dns "1.1.1.1,1.0.0.1"
nmcli connection modify ${conn_uuid} ipv4.ignore-auto-dns yes
nmcli connection modify ${conn_uuid} ipv6.dns "2606:4700:4700::1111,2606:4700:4700::1001"
nmcli connection modify ${conn_uuid} ipv6.ignore-auto-dns yes
nmcli connection show ${conn_uuid} | grep dns --color=never
echo "$(tput sgr0)"
fi
done
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment