15

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?

39

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
  • 4
    Oh Lord ... ...I made a noob mistake! Thank you. – Dale Smith Jun 27 at 1:48
  • 7
    Please mark answer as accepted, so it doesn't pop up again in a year:) – vidarlo Jun 27 at 1:54
  • Working on it. Looking for the "Accepted" button. :) – Dale Smith Jun 27 at 2:14
  • 3
    @DaleSmith It is the little check mark next to this answer here below the up and down vote arrows. – Terrance Jun 27 at 2:57
  • @Dale-smith: the button (check-mark shaped) probably appeared now, next to this answer's score. – Olivier Dulac Jun 28 at 11:08
1

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.

  • 2
    Note that there's no wildcard matching. Thus, facebook.com will not match `www.facebook.com – vidarlo Jun 28 at 13:03
  • @vidarlo I know, that screenshot was from an old example. – LogicalBranch Jun 28 at 13:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.