Skip to content

Instantly share code, notes, and snippets.

@chrisswanda
Last active August 18, 2020 12:52
Show Gist options
  • Save chrisswanda/d3e994cc4f3230fed49343fd6b2cc60f to your computer and use it in GitHub Desktop.
Save chrisswanda/d3e994cc4f3230fed49343fd6b2cc60f to your computer and use it in GitHub Desktop.
Create a user specific host file
$HOSTALIASES no longer works with glibc (https://bugs.launchpad.net/debian/+source/glibc/+bug/1483187)
For my project, I needed to create a user specifc hosts file.
First clone this repo - https://github.com/figiel/hosts.git
################ README #####################################
hosts - wrapper for libc which provides defining host aliases in a per-user file
note:
- if your libc does support it you may want to set HOSTALIASES instead of
using this wrapper, see gethostbyname(3).
compilation:
$ git clone https://github.com/figiel/hosts.git
$ cd hosts
$ make
installation:
$ mkdir ~/bin
$ cp libhostspriv.so ~/bin
$ echo 'export LD_PRELOAD=~/bin/libhostspriv.so' >> ~/.bashrc
$ logout
usage:
$ echo "127.0.0.1 new_name" >> ~/.hosts
$ nc -vz new_name 80
########################################################
For me it works on Chromium and Firefox.
echo "export LD_PRELOAD=/home/chris/Development/hosts/libhostspriv.so {firefox|brave-browser}" >> ~/.bashrc
#########################################################
Set at the system level -
cp libhostspriv.so
export LD_PRELOAD=/usr/local/lib/libhostspriv.so
###########################################################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment