TIL: $HOSTALIASES in FreeBSD
Apparently you can set the $HOSTALIASES environment variable in FreeBSD (and maybe some Linuxen? but not OpenBSD AFAICT) to point to an alternate hosts file (instead of the default /etc/hosts) for re-mapping particular hosts. This would let you do something like
$ HOSTALIASES=$HOME/hosts.txt myprog
and any name-resolution that myprog(1) does will first consult the ~/hosts.txt file.
https://man.freebsd.org/cgi/man.cgi?query=hostname&sektion=7



