What is causing the changes in /etc/resolver/ on MacOS Sierra to be noticed

[It] is enough to only open it in vim and not even change anything (just exit), previously echoed changes will be applied.

I had to use sudo vim for that to work. Running it with my regular user had no effect. My theory is that whatever is watching /etc/resolver watches for changes to the directory, and not to changes to files within it, and the reloads everything in it when it sees a change to the directory. Vim creates a swap file, by default in the same directory as the file being edited. This is a change to the directory, and is picked up by the watcher. So, when I did:

sudo vim -n /etc/resolver/example.net

where -n disable swap file creation, changes to the file were no longer picked up.


Changes to existing files in /etc/resolver are not noticed, it is only noticed when files are created or deleted in that folder.

It's the IPMonitor plugin of configd that monitors this folder.
From the source code:

status = notify_monitor_file(notify_token, resolver_directory_path, 0);

And what this function does is to set a monitor on the inode of the path. So it will only get a notification if the inode of /etc/resolver changes, not when the inode of any file within that directory changes.

In UNIX a directory is just like a file whose content is a table listing the directory content. Thus whenever you add or remove a file, this table is updated and thus the inode is updated as well, triggering the notification. If you edit a file within the directory, the inode of the directory isn't touched at all.

But you shouldn't use /etc/resolver at all on macOS, it's only kept for backward compatibility. Instead you should create a DNS entry in the Dynamic Store which you can access with the tool scutil. Please check out my reply about this topic.