centos: unknown host localhost

hy!

suddenly fetchmail cant resolve localhost anymore, so i tried ping localhost and i got

"ping: unknown host localhost"

apart from configuring apache and running out of diskspace yesterday (fixed that), i cant remember to have changed anything related to my network config. resolv.conf has this in it:

 ; generated by /sbin/dhclient-script
search members.linode.com
nameserver 97.107.133.4
nameserver 207.192.69.4
nameserver 207.192.69.5

an etc/hosts is like this:

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1       localhost localhost.localdomain
::1     localhost6.localdomain6 localhost6

can anyone tell me what i could have messed up, since the setup worked fine until today? my fqdn resolves fine from outside and from the console, its just localhost not resolving anymore i guess.

thx!

5 Replies

Check /etc/nsswitch.conf for the hosts entry

hosts:      files dns

Thanks a lot! It works again now. nsswitch.conf was empty and dated September 24, 2004, very strange.. Have you got any idea what could have happened?

How did you run out of disk space? If you were restoring files from a backup (for example) then it could have created zero length files. Patching the system might also do it if you ran out of space during the patching. Etc etc etc.

Note that the file time reported by "ls -l" doesn't necessarily mean the last time the file was changed. Normally "ls -lc" would help, but since you've now changed the file that information is missing.

There are plenty more lines in a normal nsswitch.conf; mine has the following:

passwd:     files
shadow:     files
group:      files
hosts:      files dns
bootparams: files
ethers:     files
netmasks:   files
networks:   files
protocols:  files
rpc:        files
services:   files
netgroup:   files
publickey:  files
automount:  files
aliases:    files

.

Some of those may be defaults so aren't needed

that may be the cause - i did a "yum update" and it ran out of disk-space while installing files. another start of yum update then finished properly. besides that i only configured apache. all server-processes run normally now, do you think i need some more research if anything was corrupted? thanks!

Can't hurt to look for zero length files and if any of them look important then restore them from the backups you do make… :-)

find / -size 0

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct