# [SOLVED] /etc/hosts issue

## L124RD

I was trying to configure =dev-db/mysql-5.0.70-r1 and got the following error:

```
l124rd@persephone ~ $ tail /var/tmp/portage/dev-db/mysql-5.0.70-r1/temp/mysql_install_db.log 

Neither host 'persephone' nor 'localhost' could be looked up with

/usr/bin/resolveip

Please configure the 'hostname' command to return a correct

hostname.

If you want to solve this at a later stage, restart this script

with the --force option
```

I tried to double check this by running resolveip myself:

```
l124rd@persephone ~ $ cat /etc/conf.d/hostname 

# /etc/conf.d/hostname

# Set to the hostname of this machine

HOSTNAME="persephone"

l124rd@persephone ~ $ cat /etc/hosts

127.0.0.1   persephone localhost

::1      localhost

l124rd@persephone ~ $ resolveip 127.0.0.1

Host name of 127.0.0.1 is localhost

l124rd@persephone ~ $ resolveip persephone

resolveip: Unable to find hostid for 'persephone': host not found

l124rd@persephone ~ $ resolveip localhost

resolveip: Unable to find hostid for 'localhost': host not found
```

I suspect it is a /etc/hosts issue because I can resolve DNS properly but I cannot add additional items to the /etc/hosts file:

```
l124rd@persephone ~ $ ping google.com

PING google.com (209.85.171.100) 56(84) bytes of data.

64 bytes from cg-in-f100.google.com (209.85.171.100): icmp_seq=1 ttl=244 time=163 ms

64 bytes from cg-in-f100.google.com (209.85.171.100): icmp_seq=2 ttl=244 time=163 ms

^C

--- google.com ping statistics ---

2 packets transmitted, 2 received, 0% packet loss, time 1001ms

rtt min/avg/max/mdev = 163.555/163.654/163.754/0.416 ms

l124rd@persephone ~ $ su -c "echo 209.85.171.100 testhost >> /etc/hosts"

Password: 

l124rd@persephone ~ $ cat /etc/hosts

127.0.0.1   persephone localhost

::1      localhost

209.85.171.100 testhost

l124rd@persephone ~ $ resolveip testhost

resolveip: Unable to find hostid for 'testhost': host not found

l124rd@persephone ~ $ ping testhost

ping: unknown host testhost
```

This is a young system (2-3 days old). So far the only things that I've done so far (after installing 2008.0 and updating world) was to install mysql.Last edited by L124RD on Tue Apr 14, 2009 4:33 pm; edited 1 time in total

----------

## Letharion

Just guessing.

Any chance you can't define two hostnames on the same row?

So instead of

```
127.0.0.1 persephone localhost
```

```
127.0.0.1 persephone

127.0.0.1 localhost
```

----------

## muhsinzubeir

 *Quote:*   

> l124rd@persephone ~ $ cat /etc/hosts
> 
> 127.0.0.1   persephone localhost
> 
> ::1      localhost
> ...

 

Try getting rid of that ::1 localhost....and you might want to put the ip address as well.Here is how mine looks like for comparison:

 *Quote:*   

> 127.0.0.1         gendesktop.mambo-tech.net       gendesktop      localhost
> 
> 192.168.1.2     gendesktop.mambo-tech.net       gendesktop

 

----------

## timeBandit

Your host IP cannot be 127.0.0.1, that is the reserved loopback address. You must assign persephone a real IP on your network and enter it on a separate line in /etc/hosts, as exemplified above by muhsinzubeir.

----------

## L124RD

No luck with either of those:

```
l124rd@persephone ~ $ cat /etc/hosts

127.0.0.1   persephone

127.0.0.1   localhost

AAA.BBB.CCC.DDD persephone

l124rd@persephone ~ $ resolveip localhost

resolveip: Unable to find hostid for 'localhost': host not found

l124rd@persephone ~ $ resolveip persephone

resolveip: Unable to find hostid for 'persephone': host not found

l124rd@persephone ~ $ resolveip 127.0.0.1

Host name of 127.0.0.1 is localhost

l124rd@persephone ~ $ resolveip AAA.BBB.CCC.DDD

Host name of AAA.BBB.CCC.DDD is correct.reverse.dns
```

I have another computer on the same network with a nearly identical /etc/hosts to the one I started with. I tried copying that over and also had no luck. For reference, the other computer's /etc/hosts is:

```
127.0.0.1   monocle localhost

::1      localhost

AAA.BBB.CCC.DDD persephone

AAA.BBB.EEE.FFF hades
```

----------

## timeBandit

Please refer to my post above, I believe you missed it while typing your reply.

----------

## L124RD

 *timeBandit wrote:*   

> Please refer to my post above, I believe you missed it while typing your reply.

 

I believed it was covered by the above post. I have edited the /etc/hosts to match your suggestion, however.

```
l124rd@persephone ~ $ cat /etc/hosts

127.0.0.1   localhost

AAA.BBB.CCC.DDD persephone

l124rd@persephone ~ $ resolveip 127.0.0.1

Host name of 127.0.0.1 is localhost

l124rd@persephone ~ $ resolveip localhost

resolveip: Unable to find hostid for 'localhost': host not found

l124rd@persephone ~ $ resolveip persephone

resolveip: Unable to find hostid for 'persephone': host not found
```

The other computer on the same network that is working fine:

```
l124rd@monocle > cat /etc/hosts

127.0.0.1   monocle localhost

::1      localhost

AAA.BBB.CCC.DDD persephone

AAA.BBB.EEE.FFF hades

l124rd@monocle > resolveip 127.0.0.1

Host name of 127.0.0.1 is monocle, localhost

l124rd@monocle > resolveip localhost

IP address of localhost is 127.0.0.1

l124rd@monocle > resolveip monocle

IP address of monocle is 127.0.0.1

l124rd@monocle > resolveip hades

IP address of hades is AAA.BBB.EEE.FFF

l124rd@monocle > resolveip persephone

IP address of persephone is AAA.BBB.CCC.DDD
```

----------

## timeBandit

Also, I missed this clue: *L124RD wrote:*   

> 
> 
> ```
> l124rd@persephone ~ $ cat /etc/hosts
> 
> ...

 Please post the output of nl /etc/nsswitch.conf.

----------

## L124RD

 *timeBandit wrote:*   

> Also, I missed this clue: *L124RD wrote:*   
> 
> ```
> l124rd@persephone ~ $ cat /etc/hosts
> 
> ...

 

Ah there we go!

```
l124rd@persephone ~ $ nl /etc/nsswitch.conf 

l124rd@persephone ~ $ ssh AAA.BBB.CCC.EEE wc -l /etc/nsswitch.conf

24 /etc/nsswitch.conf

l124rd@persephone ~ $ scp AAA.BBB.CCC.EEE:/etc/nsswitch.conf .

nsswitch.conf                                                           100%  508     0.5KB/s   00:00    

l124rd@persephone ~ $ sudo mv nsswitch.conf /etc/nsswitch.conf 

Password: 

l124rd@persephone ~ $ nl /etc/nsswitch.conf 

     1   # /etc/nsswitch.conf:

     2   # $Header: /var/cvsroot/gentoo/src/patchsets/glibc/extra/etc/nsswitch.conf,v 1.1 2006/09/29 23:52:23 vapier Exp $

       

     3   passwd:      compat

     4   shadow:      compat

     5   group:       compat

       

     6   # passwd:    db files nis

     7   # shadow:    db files nis

     8   # group:     db files nis

       

     9   hosts:       files dns

    10   networks:    files dns

       

    11   services:    db files

    12   protocols:   db files

    13   rpc:         db files

    14   ethers:      db files

    15   netmasks:    files

    16   netgroup:    files

    17   bootparams:  files

       

    18   automount:   files

    19   aliases:     files

l124rd@persephone ~ $ resolveip localhost

IP address of localhost is 127.0.0.1

l124rd@persephone ~ $ resolveip persephone

IP address of persephone is AAA.BBB.CCC.DDD
```

Seems to be an issue with my glibc install then... While updating the world I quickpkg'd gcc/glibc from another computer that uses the same cflags to save time. Guess I should build them anyway in case there is another similar issue.

Thanks!

----------

## lepingbeta

Hope this will help someone: http://lepingbeta.com/archives/764  :Razz: 

----------

