Don't know where to look?

You can search all my notes here

Repair /etc/resolver via Applescript automatically

I am using a local dns-server to redirect all *.home-hosts to localhost.

To prevent macOS from always using my local dns-server and only resolving *.home locally, I created a file called home inside /etc/resolvercontaining the string nameserver 127.0.0.1.

This does not play well with my VPN-client “Forti-Client” which for some reason deletes this file everytime I disconnect from a vpn. To restore this file in a quick manner, I created the following Applescript:

applescript
do shell script "sudo tee /etc/resolver/home >/dev/null <<EOF
nameserver 127.0.0.1
EOF" with administrator privileges

Using Automator, I can then easily add this script to my services-menu to quickly restore that file.

You can download the finished workflow here:

Comments

Post-Meta