I know that I can use my chosen DNS by adding the following line to
$ supersede domain-name-servers 126.96.36.199, 188.8.131.52;
I can verify that the correct DNS is being used as follows:
$ nmcli dev show | grep DNS IP4.DNS: 184.108.40.206 IP4.DNS: 220.127.116.11
But I'd like to automate the setup of my machine (Ubuntu 18.04), and therefore want to avoid editing
/etc/dhcp/dhclient.conf directly. The "simple" solution would be to append to the file:
echo "supersede domain-name-servers 18.104.22.168, 22.214.171.124;" | sudo tee -a /etc/dhcp/dhclient.conf
But this has the disadvantage that the line will be duplicated if the setup script is run twice. Is there an established way for doing this?