/etc/hosts not working

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 and chassisTwo. Pinging the hostname returns:

ping: unknown host chassisOne

My nsswitch.conf file is:

host:   files mdns4_minimal [NOTFOUND=return] dns

What am I missing?


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:

Firefox Error Screen

Good luck.