/etc/hosts not working
Solution 1
From man hosts
:
This manual page describes the format of the /etc/hosts file. This file is a simple text file that associates IP addresses with hostnames, one line per IP address. For each host a single lineshould be present with the following information:
IP_address canonical_hostname [aliases...]
Thus,
chassisOne 10.0.0.1
is wrong.
It should be
10.0.0.1 chassisOne
Solution 2
You're writing it in the wrong order, the ip
is supposed to go before the domain
.
Try using this instead:
10.0.0.1 facebook.com
10.0.0.2 google.com
Then when you navigate to facebook.com
or google.com
on your browser, it'll display the following error:
Good luck.
Related videos on Youtube
Dale Smith
By Day: I work in the telecommunications field aggregating and tapping 2G/3G/4G traffic for analysis. I've worked in Europe, North and South America. By night: I like to learn new things, drink my excellent home brewed beer, and watch something like Fring, Firefly, Castle, or Elementary. I like SciFi and WWII history for reading. Funsies: Seeing beautiful places.
Updated on September 18, 2022Comments
-
Dale Smith over 1 year
I populated
/etc/hosts
with device names and IP addresses. For example:chassisOne 10.0.0.1 chassisTwo 10.0.0.2 . . . etcetera.
I am able to ping the IP address of both
chassisOne
andchassisTwo
. Pinging the hostname returns:ping: unknown host chassisOne
My nsswitch.conf file is:
host: files mdns4_minimal [NOTFOUND=return] dns
What am I missing?
-
Dale Smith almost 5 yearsOh Lord ... ...I made a noob mistake! Thank you.
-
vidarlo almost 5 yearsPlease mark answer as accepted, so it doesn't pop up again in a year:)
-
Dale Smith almost 5 yearsWorking on it. Looking for the "Accepted" button. :)
-
Terrance almost 5 years@DaleSmith It is the little check mark next to this answer here below the up and down vote arrows.
-
ShadowRunner almost 5 years@Dale-smith: the button (check-mark shaped) probably appeared now, next to this answer's score.
-
vidarlo almost 5 yearsNote that there's no wildcard matching. Thus,
facebook.com
will not match `www.facebook.com -
LogicalBranch almost 5 years@vidarlo I know, that screenshot was from an old example.