Last active
February 17, 2025 00:30
-
-
Save chrisswanda/d3e994cc4f3230fed49343fd6b2cc60f to your computer and use it in GitHub Desktop.
Create a user specific host file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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