2

Entries in my /etc/hosts file are being ignored:

$ cat /etc/hosts
127.0.0.1   localhost
127.0.0.1   google.com

$ ping google.com
PING google.com (216.58.213.142) 56(84) bytes of data.
64 bytes from par21s03-in-f142.1e100.net (216.58.213.142): icmp_seq=1 ttl=50 time=10.3 ms

I've been through ALL the solutions suggested in the 12.04 thread but no dice.

  • Installing nscd just so I can restart it
  • Editing /etc/nsswitch.conf : it currently looks like:

    $ cat /etc/nsswitch.conf
    # /etc/nsswitch.conf
    #
    
    passwd:         compat
    group:          compat
    shadow:         compat
    gshadow:        files
    
    hosts:          dns files
    networks:       files
    
    protocols:      db files
    services:       db files
    ethers:         db files
    rpc:            db files
    
    netgroup:       nis
    

    Note: The hosts line was files dns before I started troubleshooting, I changed it to dns files as per a suggestion from the 12.04 thread. Neither ordering produced any change in the behavior of my system, where /etc/hosts is concerned.

  • Editing /etc/default/dnsmasq (No such file)

  • Disabling dnsmasq in /etc/NetworkManager/NetworkManager.conf (no such file either)
  • Creating a /etc/NetworkManager/dnsmasq.d/hosts.conf file and adding address resolution lines to it, killing dnsmasq (no such process) and doing service network-manager restart (no such service)
  • Setting up a Squid proxy server (err, this won't work for my situation, and is a hack that's outside the scope of the question!)
  • sudo chmod 644 hosts (permissions were already 644 beforehand)

I would have asked this as a comment in that thread, but I don't have enough reputation (50 needed).

By request, here's the output of systemctl list-units '[Nn]etwork*' --all:

$ systemctl list-units '[Nn]etwork*' --all
  UNIT                   LOAD      ACTIVE   SUB    DESCRIPTION
  networking.service     loaded    active   exited Raise network interfaces
● NetworkManager.service not-found inactive dead   NetworkManager.service
  network-online.target  loaded    active   active Network is Online
  network-pre.target     loaded    active   active Network (Pre)
  network.target         loaded    active   active Network

Any ideas?

right2clicky
  • 21
  • 1
  • 4
  • Please [edit] your question to include the current content of your /etc/nsswitch.conf file and the output of `systemctl list-units '[Nn]etwork*' --all` – steeldriver May 08 '18 at 12:10
  • Edits done as you requested. – right2clicky May 09 '18 at 11:26
  • Have you tried with the default `nsswitch` order i.e. `hosts: files mdns4_minimal [NOTFOUND=return] dns` ? Note that `files` should come first. – steeldriver May 09 '18 at 12:24
  • I just tried that now, and it didn't change anything. Do I need to do anything to get the system to re-check the nsswitch.conf file? Also, as I noted in my previous edit above, the nsswitch.conf had been `files dns` BEFORE I started troubleshooting. Changing it to `dns files` was a troubleshooting suggestion from the other thread. – right2clicky May 10 '18 at 07:08

2 Answers2

1

hosts: dns files

should be:

hosts: files dns

This allows the system NS to query a file first. Namely, /etc/hosts.
The order in nsswitch.conf is important - also a reboot or network restart.

B. Shea
  • 1,120
  • 13
  • 16
0

After trying all of the above, including steeldriver's suggestion in the comments I finally solved it...

...by rebooting the machine.

Now /etc/hosts works as it should.

I don't know WHICH solution did the trick, but applying all of them, and then rebooting... evidently did.

right2clicky
  • 21
  • 1
  • 4