Skip to content
HomeGitHub

The hosts file

.test is a reserved top-level domain that is never public, so Nearhost resolves aliases through /etc/hosts and not through DNS.

Nearhost owns one block and touches nothing else in the file:

# nearhost:start
127.0.0.1 myapp.test
127.0.0.1 other.test
# nearhost:end

On any alias change, Nearhost computes the desired block in full and applies it with one sudo call. The command reads the aliases from stdin, one per line:

Terminal window
sudo nearhost hosts apply

The helper rewrites only the content between the markers. If the block is absent, it creates it at the end of the file.

Nothing is removed when Nearhost quits. To remove the block, which prompts for sudo:

Terminal window
nearhost hosts clean