# network available - but localhost unreachable

## roELEo

Hi all, 

Somewhere in the last few days I borked something. Now localhost is not accessible, while my internet connection just works. Pinging localhost leaves me with 100% package loss. 

Some nmap: 

```
marvin ~ # nmap localhost

Starting nmap 3.75 ( http://www.insecure.org/nmap/ ) at 2005-05-17 12:45 CEST

WARNING:  Could not determine what interface to route packets through to 127.0.0.1, changing ping scantype to ICMP ping only

pcap_open_live: ioctl: No such device
```

And: 

```
marvin ~ # cat /etc/hosts 

127.0.0.1       marvin  localhost       

# IPV6 versions of localhost and co

::1 ip6-localhost ip6-loopback

fe00::0 ip6-localnet

ff00::0 ip6-mcastprefix

ff02::1 ip6-allnodes

ff02::2 ip6-allrouters

ff02::3 ip6-allhosts
```

My emerge info: 

 *Quote:*   

> Portage 2.0.51.19 (default-linux/x86/2005.0, gcc-3.4.3, glibc-2.3.5-r0, 2.6.11-gentoo-r8 i686)
> 
> =================================================================
> 
> System uname: 2.6.11-gentoo-r8 i686 AMD Athlon(tm) XP 2600+
> ...

 

(yeah, I know, I shouldn't have started playing with gentopia)

----------

## Spooky Ghost

What does the hosts line in /etc/nsswitch.conf contain?  You need at least files and dns.

```
hosts:       files dns
```

----------

## roELEo

Let's see: 

```
marvin ~ # cat /etc/nsswitch.conf 

# /etc/nsswitch.conf:

# $Header: /home/cvsroot/gentoo-src/rc-scripts/etc/nsswitch.conf,v 1.4 2002/11/18 19:39:22 azarah Exp $

passwd:      compat

shadow:      compat

group:       compat

# passwd:    db files nis

# shadow:    db files nis

# group:     db files nis

hosts:       files dns

networks:    files dns

services:    db files

protocols:   db files

rpc:         db files

ethers:      db files

netmasks:    files

netgroup:    files

bootparams:  files

automount:   files

aliases:     files
```

Yeah, it's there.

----------

## roELEo

Some more info:

```
 marvin ~ # /sbin/ifconfig lo 127.0.0.1 up

SIOCSIFADDR: No such device

lo: unknown interface: No such device

lo: unknown interface: No such device

```

And: 

```
marvin ~ # ifconfig -a

eth0      Link encap:Ethernet  HWaddr 00:0C:6E:C8:5C:EC  

          inet addr:10.0.0.150  Bcast:10.0.0.255  Mask:255.255.255.0

          UP BROADCAST NOTRAILERS RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:37296 errors:0 dropped:0 overruns:0 frame:0

          TX packets:35699 errors:16 dropped:0 overruns:0 carrier:16

          collisions:0 txqueuelen:1000 

          RX bytes:34372928 (32.7 Mb)  TX bytes:5947390 (5.6 Mb)

          Interrupt:5 Base address:0x2000 

eth1      Link encap:Ethernet  HWaddr 00:26:54:13:0D:54  

          BROADCAST MULTICAST  MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

          Interrupt:11 Base address:0x9000 

eth2      Link encap:UNSPEC  HWaddr 00-E0-18-00-00-37-8D-4A-00-00-00-00-00-00-00-00  

          BROADCAST MULTICAST  MTU:1500  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000 

          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

sit0      Link encap:IPv6-in-IPv4  

          NOARP  MTU:1480  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

usb_kings Link encap:Local Loopback  

          LOOPBACK  MTU:16436  Metric:1

          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0 

          RX bytes:0 (0.0 b)  TX bytes:0 (0.0 b)

```

Last edited by roELEo on Tue May 17, 2005 11:35 am; edited 1 time in total

----------

## Spooky Ghost

And in /etc/host.conf:

```
order hosts, bind
```

If you are familiar with strace you could also

```
strace ping localhost
```

and make sure there is a line like

```
read(4, "# /etc/hosts:  This file describ"..., 4096) = 543
```

in the output.  You might want a comment at the top of /etc/hosts to make it easier to identify.

----------

## roELEo

My /etc/host.conf is: 

```
# /etc/host.conf:

# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/files/2.3.4/host.conf,v 1.2 2$

# The  file /etc/host.conf contains configuration information specific to

# the resolver library.  It should contain one configuration keyword  per

# line,  followed by appropriate configuration information.  The keywords

# recognized are order, trim, mdns, multi, nospoof, spoof, and reorder.

# This keyword specifies how host lookups are to be performed. It

# should be followed by one or more lookup methods, separated by

# commas.  Valid methods are bind, hosts, and nis.

#

order hosts, bind

# Valid values are on and off. If set to on, the resolv+ library treats

# the .local top level domain as link-local domain and sends multicast

# DNS requests to the multicast address 224.0.0.251 port 5353 instead

# of normal DNS requests. If you already use the .local domain in your

# nameserver configuration you will have to switch this option off.

#

mdns off

# Valid  values are on and off.  If set to on, the resolv+ library

# will return all valid addresses for a host that appears  in  the

# /etc/hosts  file,  instead  of  only  the first.  This is off by

# default, as it may cause a substantial performance loss at sites

# with large hosts files.

#

multi off

```

----------

## roELEo

...and doing a strace ping localhost gives this output: 

(which I'm loking over right now)

```
execve("/bin/ping", ["ping", "localhost"], [/* 44 vars */]) = 0

uname({sys="Linux", node="marvin", ...}) = 0

brk(0)                                  = 0x8063000

access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)

open("/etc/ld.so.cache", O_RDONLY)      = 3

fstat64(3, {st_mode=S_IFREG|0644, st_size=129241, ...}) = 0

mmap2(NULL, 129241, PROT_READ, MAP_PRIVATE, 3, 0) = 0xb7fc9000

close(3)                                = 0

open("/lib/libresolv.so.2", O_RDONLY)   = 3

read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\300#\0"..., 512) = 512

fstat64(3, {st_mode=S_IFREG|0755, st_size=73408, ...}) = 0

mmap2(NULL, 84180, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb7fb4000

mprotect(0xb7fc4000, 18644, PROT_NONE)  = 0

mmap2(0xb7fc5000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x10) = 0xb7fc5000

mmap2(0xb7fc7000, 6356, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7fc7000

close(3)                                = 0

open("/lib/libc.so.6", O_RDONLY)        = 3

read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\260P\1"..., 512) = 512

fstat64(3, {st_mode=S_IFREG|0755, st_size=1348080, ...}) = 0

mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7fb3000

mmap2(NULL, 1260732, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb

7e7f000

mprotect(0xb7fac000, 27836, PROT_NONE)  = 0

mmap2(0xb7fad000, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x12d) = 0xb7fad000

mmap2(0xb7fb1000, 7356, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb7fb1000

close(3)                                = 0

mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7e7e000

mprotect(0xb7fad000, 4096, PROT_READ)   = 0

set_thread_area({entry_number:-1 -> 6, base_addr:0xb7e7e6b0, limit:1048575, seg_32bit:1, contents:0, read_exec_only:0, limit_in_pages:1, seg_not_present:0, useable:1}) = 0

munmap(0xb7fc9000, 129241)              = 0

open("/dev/urandom", O_RDONLY)          = 3

read(3, "\246\305\225\21", 4)           = 4

close(3)                                = 0

socket(PF_INET, SOCK_RAW, IPPROTO_ICMP) = 3

getuid32()                              = 0

setuid32(0)                             = 0

brk(0)                                  = 0x8063000

brk(0x8084000)                          = 0x8084000

gettimeofday({1116330366, 102843}, NULL) = 0

getpid()                                = 18273

open("/etc/resolv.conf", O_RDONLY)      = 4

fstat64(4, {st_mode=S_IFREG|0644, st_size=33, ...}) = 0

mmap2(NULL, 131072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7fc9000

read(4, "nameserver 10.0.0.138\nsearch lan"..., 131072) = 33

read(4, "", 131072)                     = 0

close(4)                                = 0

munmap(0xb7fc9000, 131072)              = 0

socket(PF_FILE, SOCK_STREAM, 0)         = 4

fcntl64(4, F_GETFL)                     = 0x2 (flags O_RDWR)

fcntl64(4, F_SETFL, O_RDWR|O_NONBLOCK)  = 0

connect(4, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)

close(4)                                = 0

socket(PF_FILE, SOCK_STREAM, 0)         = 4

fcntl64(4, F_GETFL)                     = 0x2 (flags O_RDWR)

fcntl64(4, F_SETFL, O_RDWR|O_NONBLOCK)  = 0

connect(4, {sa_family=AF_FILE, path="/var/run/nscd/socket"}, 110) = -1 ENOENT (No such file or directory)

close(4)                                = 0

open("/etc/nsswitch.conf", O_RDONLY)    = 4

fstat64(4, {st_mode=S_IFREG|0644, st_size=498, ...}) = 0

mmap2(NULL, 131072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7fc9000

read(4, "# /etc/nsswitch.conf:\n# $Header:"..., 131072) = 498

read(4, "", 131072)                     = 0

close(4)                                = 0

munmap(0xb7fc9000, 131072)              = 0

open("/etc/ld.so.cache", O_RDONLY)      = 4

fstat64(4, {st_mode=S_IFREG|0644, st_size=129241, ...}) = 0

mmap2(NULL, 129241, PROT_READ, MAP_PRIVATE, 4, 0) = 0xb7fc9000

close(4)                                = 0

open("/lib/libnss_files.so.2", O_RDONLY) = 4

read(4, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\220\31"..., 512) = 512

fstat64(4, {st_mode=S_IFREG|0755, st_size=39824, ...}) = 0

mmap2(NULL, 41576, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 4, 0) = 0xb7e73000

mmap2(0xb7e7c000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 4, 0x8) = 0xb7e7c000

close(4)                                = 0

munmap(0xb7fc9000, 129241)              = 0

open("/etc/host.conf", O_RDONLY)        = 4

fstat64(4, {st_mode=S_IFREG|0644, st_size=1302, ...}) = 0

mmap2(NULL, 131072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7fc9000

read(4, "# /etc/host.conf:\n# $Header: /va"..., 131072) = 1302

read(4, "", 131072)                     = 0

close(4)                                = 0

munmap(0xb7fc9000, 131072)              = 0

open("/etc/hosts", O_RDONLY)            = 4

fcntl64(4, F_GETFD)                     = 0

fcntl64(4, F_SETFD, FD_CLOEXEC)         = 0

fstat64(4, {st_mode=S_IFREG|0644, st_size=219, ...}) = 0

mmap2(NULL, 131072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7fc9000

read(4, "# marvinhosts\n127.0.0.1\tmarvin\tl"..., 131072) = 219

close(4)                                = 0

munmap(0xb7fc9000, 131072)              = 0

socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 4

connect(4, {sa_family=AF_INET, sin_port=htons(1025), sin_addr=inet_addr("127.0.0.1")}, 16) = 0

getsockname(4, {sa_family=AF_INET, sin_port=htons(32946), sin_addr=inet_addr("10.0.0.150")}, [16]) = 0

close(4)                                = 0

setsockopt(3, SOL_RAW, ICMP_FILTER, ~(ICMP_ECHOREPLY|ICMP_DEST_UNREACH|ICMP_SOURCE_QUENCH|ICMP_REDIRECT|ICMP_TIME_EXCEEDED|ICMP_PARAMETERPROB), 4) = 0

setsockopt(3, SOL_IP, IP_RECVERR, [1], 4) = 0

setsockopt(3, SOL_SOCKET, SO_SNDBUF, [324], 4) = 0

setsockopt(3, SOL_SOCKET, SO_RCVBUF, [65536], 4) = 0

getsockopt(3, SOL_SOCKET, SO_RCVBUF, [131072], [4]) = 0

fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0

mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb7fe8000

write(1, "PING marvin (127.0.0.1) 56(84) b"..., 46PING marvin (127.0.0.1) 56(84) bytes of data.

) = 46

setsockopt(3, SOL_SOCKET, SO_TIMESTAMP, [1], 4) = 0

setsockopt(3, SOL_SOCKET, SO_SNDTIMEO, "\1\0\0\0\0\0\0\0", 8) = 0

setsockopt(3, SOL_SOCKET, SO_RCVTIMEO, "\1\0\0\0\0\0\0\0", 8) = 0

rt_sigaction(SIGINT, {0x804ba20, [], SA_INTERRUPT}, NULL, 8) = 0

rt_sigaction(SIGALRM, {0x804ba20, [], SA_INTERRUPT}, NULL, 8) = 0

rt_sigaction(SIGQUIT, {0x804ba30, [], SA_INTERRUPT}, NULL, 8) = 0

gettimeofday({1116330366, 148453}, NULL) = 0

ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0

ioctl(1, TIOCGWINSZ, {ws_row=44, ws_col=80, ws_xpixel=0, ws_ypixel=0}) = 0

gettimeofday({1116330366, 149829}, NULL) = 0

gettimeofday({1116330366, 150252}, NULL) = 0

sendmsg(3, {msg_name(16)={sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("127.0.0.1")}, msg_iov(1)=[{"\10\0\265MaG\0\1~\331\211B\354J\2\0\10\t\n\v\f\r\16\17"..., 64}], msg_controllen=0, msg_flags=0}, 0) = 64

recvmsg(3, 0xbfffe2e0, 0)               = -1 EAGAIN (Resource temporarily unavailable)

gettimeofday({1116330367, 151917}, NULL) = 0

gettimeofday({1116330367, 152391}, NULL) = 0

sendmsg(3, {msg_name(16)={sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("127.0.0.1")}, msg_iov(1)=[{"\10\0YDaG\0\2\177\331\211BGS\2\0\10\t\n\v\f\r\16\17\20"..., 64}], msg_controllen=0, msg_flags=0}, 0) = 64

recvmsg(3, 0xbfffe2e0, 0)               = -1 EAGAIN (Resource temporarily unavailable)
```

I cut if off here because it's only repeating the EAGAIN (Resource temporarily unavailable) code snippet.Last edited by roELEo on Tue May 17, 2005 11:54 am; edited 1 time in total

----------

## roELEo

 *Spooky Ghost wrote:*   

> and make sure there is a line like
> 
> ```
> read(4, "# /etc/hosts:  This file describ"..., 4096) = 543
> ```
> ...

 

The first line of /etc/hosts now reads # marvinhosts, so looking at the strace output I see: 

```
read(4, "# marvinhosts\n127.0.0.1\tmarvin\tl"..., 131072) = 219

close(4)                                = 0 
```

----------

## Spooky Ghost

I think you are on a better line with the failure of ifconfig.  net.lo in /etc/init.d is the script that should bring the loopback interface up.  If you do rc-update show you should see that this is started in the boot level.  I don't think it is possible to configure the loopback device as a kernel module so it's unlikely that this is messed up.  Do you have anything in the dmesg output which relates to the lo device?

(Actually if I had paid more attention to your first comment, nmap has resolved localhost to the correct address so nsswitch.conf and host.conf weren't going to be the problem.)

----------

## roELEo

net.lo is definitely started at boot: 

```
 marvin # rc-update show | grep net.lo

              net.lo | boot    
```

And dmesg doesn't cough up anything related to net.lo as far as I can see. 

```
marvin ~ # dmesg | grep net

forcedeth.c: Reverse Engineered nForce ethernet driver. Version 0.31.

3c59x: Donald Becker and others. www.scyld.com/network/vortex.html

eth1394: eth2: IEEE-1394 IPv4 over 1394 Ethernet (fw-host0)

marvin ~ # dmesg | grep NET

NET: Registered protocol family 2

NET: Registered protocol family 1

NET: Registered protocol family 10

NET: Registered protocol family 17

NET: Registered protocol family 31
```

I'm looking at it some more...   :Wink: 

----------

## roELEo

For now, I'll start with downgrading from the very unstable udev/hal packages that came with the Gentopia overlay. 

That's just too much living on the edge. After that, let's see what is still wrong...   :Smile: 

----------

## roELEo

Well, that didn't do it.   :Sad: 

What I did see is that, on startup, I get an error that /etc/init.d/net.eth1 doesn't exist. 

Update: That last 'problem' is now fixed. net.eth1 was still running around in my default runlevels for one reason or another.   :Smile: 

Regarding lo being unavailable, even a new kernel (2.6.11-r9) doesn't fix it.

----------

## roELEo

Since I have been unable to solve this problem, I opened a bug for it here: 

https://bugs.gentoo.org/show_bug.cgi?id=93166

----------

