DarkMatter in Cyberspace
  • Home
  • Categories
  • Tags
  • Archives

Using User Level Hosts File


Some stupid web apps hard-coded self-defined hostnames, such as cdh001, instead of IP address "171.15.106.220". To open pages on these web sites, you have to modify your /etc/hosts by adding:

172.15.106.220             cdh001
172.15.106.221             cdh002
172.15.106.222             cdh003
172.15.106.223             cdh004
172.15.106.224             cdh005
172.15.106.225             cdh006

But this is far from an ideal solution, because these name resolutions are all temporary. They should be defined without root privileges.

The following method works on Ubuntu 16.04:

cat << EOF > ~/.hosts
cdh001  172.15.106.220
cdh002  172.15.106.221
cdh003  172.15.106.222
cdh004  172.15.106.223
cdh005  172.15.106.224
cdh006  172.15.106.225
EOF

export HOSTALIASES=~/.hosts
firefox

Now in the opened Firefox browser, you can use 'http://cdh001' instead of 'http://172.15.106.220'.



Published

Jan 3, 2019

Last Updated

Jan 3, 2019

Category

Tech

Tags

  • dns 4
  • hosts 1
  • linux 158

Contact

  • Powered by Pelican. Theme: Elegant by Talha Mansoor