How to Change DNS of network from Terminal? [duplicate]

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 8.8.8.8 8.8.4.4 (or other dns servers)      
   nmcli> save
   nmcli> quit 

nmcli connection down your_connection_name
nmcli connection up your_connection_name