# /etc/host.conf ?

## dju`

Hello,

I was just wondering why there is no /etc/host.conf (where I want to set order hosts,bind) because only the dns specified in resolv.conf are used, not my hosts file before. For example, I have 127.0.0.1 localhost specified in the hosts file, and :

```
# host localhost

Host localhost not found: 3(NXDOMAIN)

```

So what can I do please ?

----------

## silverter

What does your /etc/resolv.conf look like ? I have these in my resolv.conf:

```
domain <my domainname>

search <some domain> <another domain>

namerserver <my nameserver>

```

And I get the following: 

```
-(/etc)-> host localhost

localhost.<my domainname> has address 127.0.0.1

```

my /etc/hosts has

```
127.0.0.1 locahost
```

hope this helps.

PS: I don't know why there's no host.conf. If you find out, just post here.

----------

## dju`

mmm, it seems that host/nslookup doesn't care about /etc/hosts, but ping and all others programs do :

```
# host localhost

Host localhost not found: 3(NXDOMAIN)

# ping localhost

PING localhost (127.0.0.1): 56 octets data

64 octets from 127.0.0.1: icmp_seq=0 ttl=64 time=0.0 ms

--- localhost ping statistics ---

1 packets transmitted, 1 packets received, 0% packet loss

round-trip min/avg/max = 0.0/0.0/0.0 ms
```

that's weird! why is your host localhost working then ?

----------

## Sledgy

ping uses /etc/nsswitch.conf

host doesn't, since it's a dns utility...

 :Wink: 

ciao

  sledgy ;-]

----------

## fatcat.00

His DNS server is resolving the name "localhost" to 127.0.0.1.  Simple answer, but thats it.

"host" and "nslookup" and "dig" all ignore /etc/hosts because they are tools to troubleshoot *DNS* problems.  They do not use the OS's gethostbyname() function, but instead have resolver code built into them.

/etc/hosts - tells the OS's resolver about any locally defined hosts to resolve

/etc/resolv.conf - tells the OS's resolver about the DNS servers and options to use

/etc/nsswitch.conf - tells the OS's resolver what order to perform resolution in...for example, my nsswitch.conf says:

```
hosts:      files dns
```

This means to try to resolve hostnames first by looking in /etc/hosts, and then if the hostname isn't found to use DNS (according to how its defined in resolv.conf).

Whew!  That was more than I wanted to write, and I think you already knew most if not all of it.  Best to be thorough though, eh?

Good Luck!

-- Fatcat

----------

## dju`

thanks for these answers, it's all clear now  :Smile: 

----------

