You can change IPv4 DNS settings the graphical way as answered here
But if you're wondering how to do the same thing using command line, you have to list files in
/etc/NetworkManager/system-connections directory with
There has to be a file with the name of your connection, mine is called
Wired Connection 1.
So we need to edit the file and add DNS servers in it:
Sudo nano "/etc/NetworkManager/system-connections/Wired connection 1"
Add as many DNS servers as you like under the
[ipv4] section and seperate them with semicolons
; and also put a
; at the end of the last DNS server like this:
You can just delete this line if you don't want to assign any dns.
Also you have to add this line
ignore-auto-dns=true to ignore DHCP provided DNS servers (like the DNS server set in router's config):
A little context to this answer:
I was trying to figure out what file gets edited when I add a DNS server in the GUI's DNS settings, so I was running this command for 16+ hours:
sudo grep -rs "126.96.36.199" / which was scanning all files on my Ubuntu virtual machine but it never finished even after running that long, but I knew it's possible that the file could exist in
/etc/NetworkManager so I ran the
grep again pointing at that directory and found this:
/etc/NetworkManager/system-connections/Wired connection 1:dns=188.8.131.52; so I came back here to write an answer only to find out Lekensteyn has already pointed this out in the comments on the accepted answer.