Want to read my ramblings?

I write what I write, read if you read.

nmcli Set DNS

Posted at — Nov 17, 2019

Setting the DNS of my current wifi to Google’s DNS servers. Mostly taken from serverfault.

WIFI_CON=$(nmcli device status | grep wifi | head -n 1 | sed 's/^[[:alnum:]]\+ \+wifi \+[[:alnum:]]\+  \+//')
nmcli connection modify "${WIFI_CON}" ipv4.dns "8.8.8.8 8.8.4.4"
nmcli connection modify "${WIFI_CON}" ipv6.dns "2001:4860:4860::8888 2001:4860:4860::8844"
nmcli connection modify "${WIFI_CON}" ipv4.ignore-auto-dns yes
nmcli connection modify "${WIFI_CON}" ipv6.ignore-auto-dns yes
nmcli connection down "${WIFI_CON}"
nmcli connection up "${WIFI_CON}"

To check that everything has been correctly set

cat /etc/resolv.conf