I would like to add a user specific host file on my Mac (El Capitan 10.11.5) to a users home directory and have this be checked in addition to /etc/hosts
when resolving domain names.
I found a similar answer here. This answer was a flat no because that individual did not have superuser privileges. This is not the case for me because I do in fact have superuser privileges.
I found another answer here, but that doesn't seem to work on my machine. This answer involves setting the HOSTALIASES
environment variable to ~/.hosts
, but no addition to the ~/.hosts
file ever had any implications in my web browser, which is the goal of me wanting to create a user specific host file.
NOTE: After reading through a bit of the man pages of bash, the correct environment variable on mac that the second answer needs is HOSTFILE
. However, this still didn't affect anything. Thoughts on this?
EDIT: This is for a single user environment as MrWonderful suggested. However, I would like for the hosts setting of one user to be unaffected but another user.
Thoughts?
HOSTALIASES=$HOME/hosts sudo -E dtruss ping foobar
shows the only file opened is/etc/hosts
.HOSTFILE=$HOME/hosts
has the same result. Thehosts(5)
man page states only/etc/hosts
is read. Thehostname(7)
man page statesHOSTALIASES
is used. Ugh, more broken Apple software.