# Name resolution priority (/etc/hosts or DNS).

## cibonato

Hello, I've been trying to set the priority which my computer should resolv names but I think I'm doing something wrong. I have a couple of entries in /etc/hosts files (they are related with virtual machine the computer is running). I can ping those machines using the name I gave them in /etc/hosts file:

```
$ ping gildavm

PING gildavm.localdomain (192.168.57.131) 56(84) bytes of data.

64 bytes from gildavm.localdomain (192.168.57.131): icmp_req=1 ttl=64 time=0.139 ms

64 bytes from gildavm.localdomain (192.168.57.131): icmp_req=2 ttl=64 time=0.094 ms
```

On the other hand, if I use host or nslookup things seem not to work:

```
$ host gildavm

Host gildavm not found: 3(NXDOMAIN)
```

```
$ nslookup gildavm

Server:      my_dns_server_ip

Address:   my_computer_ip#53

** server can't find gildavm: NXDOMAIN

```

Besides that, if I write http://gildavm at the browser it doesn't work either. The file /etc/host.conf has the line order hosts,bind and /etc/nsswitch.conf has hosts: file dns.

Suggestions?

Thank you.

----------

## PaulBredbury

 *cibonato wrote:*   

> hosts: file dns

 

You missed out the 's'  :Wink: 

Should be:  files dns

----------

## Hu

 *cibonato wrote:*   

> On the other hand, if I use host or nslookup things seem not to work:
> 
> ```
> $ host gildavm
> 
> ...

 This is normal.  Those tools make DNS queries.  If the result cannot be found via DNS, then they will return a failure, even if the name could have been found through some other means.  PaulBredbury's suggestion as to the cause of your real problem looks sound to me.

----------

## cibonato

 *PaulBredbury wrote:*   

>  *cibonato wrote:*   hosts: file dns 
> 
> You missed out the 's' 
> 
> Should be:  files dns

 

It was a typo.   :Embarassed:  Sorry for the noise, the beloved s is where it's supposed to be.

Well, if the applications work this way it's OK. That's the way things are!  :Smile: 

Thank you all.

----------

