Mac & DNS - Setting up the nameserver
sudo networksetup -setdnsservers Ethernet 185.228.168.168
sudo networksetup -setdnsservers Wi-Fi 185.228.168.168


The Ethernet/Wi-Fi bit is the name of the network connection in the Network control panel.

You'll need sudo rights, as this has to be run as by and admin, and needs them to interactively enter a password if you leave that out.

But, you can easily script the above to run remotely.

From the man page (Sierra):


  -setdnsservers networkservice dns1 [dns2] [...]
  
  Use this command to specify the IP addresses of servers you want
  the specified  to use to resolve domain names. You can list
  any number of servers (replace dns1, dns2, and so on with the IP addresses of
  domain name servers). If you want to clear all DNS entries for the specified
  network service, type "empty" in place of the DNS server names.