I know how to change the DNS of my network from GUI Network Manager:

  1. Right click on the network manager icon in the panel and choose "Edit connections..."
  2. Select your connection from the wired or wireless tab, choose "Edit"
  3. Choose IPv4 settings tab
  4. Switch method to "Automatic (DHCP) addresses only"
  5. Enter the DNS you want in the box "Additional DNS servers" and press "Apply"

How do I do exactly the same thing from Terminal?


1 Answer 1


nmcli connection show --active to obtain active connection name
nmcli connection edit double tab to list available connections and chose appropriate

   nmcli> remove ipv4.dns  
   nmcli> set ipv4.ignore-auto-dns yes
   nmcli> set ipv4.dns (or other dns servers)      
   nmcli> save
   nmcli> quit 

nmcli connection down your_connection_name
nmcli connection up your_connection_name

  • 3
    I think you also have to set ipv4.ignore-auto-dns: yes
    – Thomas
    Jan 14, 2016 at 18:05
  • 1
    Careful with nmcli connection down, if you are on a remote ssh session you can lose connection to the node!! I think is better to call /etc/init.d/network restart Jun 12, 2018 at 7:03
  • There's also nmcli connection modify "Wired connection 1" ipv4.dns "" and the default that most people see cant be removed because I'm pretty sure It's seen by ip route show
    – user610658
    Nov 27, 2018 at 13:37
  • If you care about speed and privacy you might prefer using, (Cloudflare) instead of Google's one. Sep 14, 2019 at 18:35
  • /etc/init.d/network restart did not work. better yet, just do both commands with && between so it will come right back w/o losing connection. nmcli connection down && nmcli connection up
    – Dan
    Sep 11, 2020 at 0:00

Not the answer you're looking for? Browse other questions tagged or ask your own question.