I needed to use particular dns and would change them quickly (with a click)
here is how i did it:
First, here command for make modification by terminal:
sudo networksetup -setdnsservers <networkservice> DNS1, DNS2, DNS3
How to obtain a list of your network services:
networksetup -listallnetworkservices
you will obtain outcome like below:

In my case i have to change Wi-fi dns, so (as example i’ve used Google dns 8.8.8.8 and 8.8.8.4 ), opening terminal and running the following command , DNS will be changed:
“sudo networksetup -setdnsservers Wi-Fi 8.8.8.8 8.8.8.4”
But how to run it with a click ? using Apple script : open it and insert the following commands :
First row executes the command described above , while second line brings up a message that tells us that the command was executed (clearly is optional) .
After that save as application and work is ended; a click will be enough to change your dns
Here is the result after clicking (you will be prompted for the root password )

Looking Dns section we can see that they have been modified





