Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
can't find localhost [Solved]
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
l_bratch
Guru
Guru


Joined: 08 Feb 2005
Posts: 494
Location: Jersey

PostPosted: Thu Jan 26, 2006 8:31 pm    Post subject: can't find localhost [Solved] Reply with quote

I recently ran etc-update after a long time, and foolishly told it to overwrite previous config files without checking what it was changing.

As a result, I can no longer ping localhost or cpqserver properly (cpqserver is the hostname).
Code:
bratch@cpqserver ~ $ ping localhost
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost.jtibs.net (127.0.0.1): icmp_seq=1 ttl=64 time=0.059 ms

--- localhost ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.059/0.063/0.068/0.009 ms

Code:
bratch@cpqserver ~ $ ping cpqserver
ping: unknown host cpqserver

Any ideas what's going on here?

If any config files are needed, I'll post them.


Last edited by l_bratch on Wed Feb 01, 2006 12:47 pm; edited 1 time in total
Back to top
View user's profile Send private message
Qux
n00b
n00b


Joined: 19 Dec 2002
Posts: 20
Location: Paris, France

PostPosted: Thu Jan 26, 2006 9:12 pm    Post subject: Reply with quote

Methinks you have badly damaged your /etc/hosts or your /etc/conf.d.net !

Do you have such lines in your /etc/hosts :

Code:
127.0.0.1       localhost
XXX.YYY.ZZZ.WWW   cpqserver

_________________
-- Quxy
Back to top
View user's profile Send private message
l_bratch
Guru
Guru


Joined: 08 Feb 2005
Posts: 494
Location: Jersey

PostPosted: Thu Jan 26, 2006 10:51 pm    Post subject: Reply with quote

I thought it might be one of those two, but they are both fine:
Code:
bratch@cpqserver ~ $ cat /etc/hosts
# /etc/hosts:  This file describes a number of hostname-to-address
#              mappings for the TCP/IP subsystem.  It is mostly
#              used at boot time, when no name servers are running.
#              On small systems, this file can be used instead of a
#              "named" name server.  Just add the names, addresses
#              and any aliases to this file...
# $Header: /home/cvsroot/gentoo-src/rc-scripts/etc/hosts,v 1.8 2003/08/04 20:12:25 azarah Exp $
#

127.0.0.1       localhost cpqserver
192.168.0.1     bratchcpqserver
192.168.0.2     bratchmshdsktop
192.168.0.3     bratchtshlaptop

Code:
bratch@cpqserver ~ $ cat /etc/conf.d/net
iface_eth0="192.168.0.4 broadcast 192.168.0.255 netmask 255.255.255.0"
gateway="eth0/192.168.0.1"
Back to top
View user's profile Send private message
Qux
n00b
n00b


Joined: 19 Dec 2002
Posts: 20
Location: Paris, France

PostPosted: Fri Jan 27, 2006 7:14 am    Post subject: Reply with quote

ok, second try :)

What does
Code:
cat /proc/sys/net/ipv4/icmp_echo_ignore_all

say ?

If the answer is 1, you may have a new

Code:
net.ipv4.icmp_echo_ignore_all = 1


in your /etc/sysctl.conf

Otherwise, do you have iptables running ?

By the way, do other network activity still work ?
Did you reboot after the etc-update or are you still in the same session ?
_________________
-- Quxy
Back to top
View user's profile Send private message
l_bratch
Guru
Guru


Joined: 08 Feb 2005
Posts: 494
Location: Jersey

PostPosted: Mon Jan 30, 2006 4:21 pm    Post subject: Reply with quote

Code:
cpqserver bratch # cat /proc/sys/net/ipv4/icmp_echo_ignore_all
0

So it's not that...

iptables isn't running, other network activity still works, as in DNS to my ISP still works, and I can the rest of my network fine.

Also I have rebooted since the update.
Back to top
View user's profile Send private message
turtles
Veteran
Veteran


Joined: 31 Dec 2004
Posts: 1698

PostPosted: Mon Jan 30, 2006 10:26 pm    Post subject: Reply with quote

You probably alredy checked
Code:
/etc/conf.d/hostname
but thats all I can think of.
cheers
turtles
Back to top
View user's profile Send private message
l_bratch
Guru
Guru


Joined: 08 Feb 2005
Posts: 494
Location: Jersey

PostPosted: Mon Jan 30, 2006 11:05 pm    Post subject: Reply with quote

Alas, I already have:
Code:
cpqserver bratch # cat /etc/conf.d/hostname
# /etc/conf.d/hostname

# Set to the hostname of this machine
HOSTNAME="bratchmshdsktop"

:cry:

Thanks for your help though.
Back to top
View user's profile Send private message
turtles
Veteran
Veteran


Joined: 31 Dec 2004
Posts: 1698

PostPosted: Tue Jan 31, 2006 4:22 pm    Post subject: Reply with quote

I bet you tried this too..
Quote:
Code Listing 8: Setting the domainname

# nano -w /etc/conf.d/domainname

(Set the DNSDOMAIN variable to your domain name)
DNSDOMAIN="homenetwork"

If you have a NIS domain (if you don't know what that is, then you don't have one), you need to define that one too:

Code Listing 9: Setting the NIS domainname

# nano -w /etc/conf.d/domainname

(Set the NISDOMAIN variable to your NIS domain name)
NISDOMAIN="my-nisdomain"

Now add the domainname script to the default runlevel:

Code Listing 10: Adding domainname to the default runlevel

# rc-update add domainname default

Back to top
View user's profile Send private message
l_bratch
Guru
Guru


Joined: 08 Feb 2005
Posts: 494
Location: Jersey

PostPosted: Tue Jan 31, 2006 6:19 pm    Post subject: Reply with quote

Code:
bratch@bratchmshdsktop ~ $ cat /etc/conf.d/domainname
# /etc/conf.d/domainname

# When setting up resolv.conf, what should take precedence?
#  0 = let dhcp/whatever override DNSDOMAIN
#  1 = override dhcp/whatever with DNSDOMAIN

OVERRIDE=1

# To have a proper FQDN, you need to setup /etc/hosts and /etc/resolv.conf
# (domain entry in /etc/resolv.conf and FQDN in /etc/hosts).
#
# DNSDOMAIN merely sets the domain entry in /etc/resolv.conf, see
# the resolv.conf(5) manpage for more info.
 
DNSDOMAIN=""

# For information on setting up NIS, please see:
#   http://www.linux-nis.org/nis-howto/HOWTO/
 
NISDOMAIN=""
As you can see DNSDOMAIN is blank, but then again so is the DNSDOMAIN field on every other machine on this network.

the domainname script is in the default runlevel however.
Back to top
View user's profile Send private message
Qux
n00b
n00b


Joined: 19 Dec 2002
Posts: 20
Location: Paris, France

PostPosted: Tue Jan 31, 2006 7:13 pm    Post subject: Reply with quote

Ok... this one is fun !

What if you start a tcpdump in another shell while pinging localhost :

Code:
tcpdump -ilo

_________________
-- Quxy
Back to top
View user's profile Send private message
l_bratch
Guru
Guru


Joined: 08 Feb 2005
Posts: 494
Location: Jersey

PostPosted: Tue Jan 31, 2006 7:31 pm    Post subject: Reply with quote

Code:
cpqserver bratch # tcpdump -ilo
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on lo, link-type EN10MB (Ethernet), capture size 96 bytes
19:20:51.467291 IP localhost.jtibs.net > localhost.jtibs.net: icmp 64: echo request seq 1
19:20:51.467330 IP localhost.jtibs.net > localhost.jtibs.net: icmp 64: echo reply seq 1
19:20:52.468392 IP localhost.jtibs.net > localhost.jtibs.net: icmp 64: echo request seq 2
19:20:52.468422 IP localhost.jtibs.net > localhost.jtibs.net: icmp 64: echo reply seq 2
19:20:53.469237 IP localhost.jtibs.net > localhost.jtibs.net: icmp 64: echo request seq 3
19:20:53.469261 IP localhost.jtibs.net > localhost.jtibs.net: icmp 64: echo reply seq 3
19:20:54.470082 IP localhost.jtibs.net > localhost.jtibs.net: icmp 64: echo request seq 4
19:20:54.470109 IP localhost.jtibs.net > localhost.jtibs.net: icmp 64: echo reply seq 4

8 packets captured
24 packets received by filter
0 packets dropped by kernel

Although it appears localhost is being resolved correctly, you may notice that it's actually being answered by my ISP (jtibs.net) rather than the local machine.
Back to top
View user's profile Send private message
Qux
n00b
n00b


Joined: 19 Dec 2002
Posts: 20
Location: Paris, France

PostPosted: Tue Jan 31, 2006 9:37 pm    Post subject: Reply with quote

Hmmm.... Not sure this is your ISP (or if it is, I want the same, woa, 39ns for a ping, great!!!)

I see three problems here :

1) localhost is not localhost but localhost.jtibs.net
jtibs.net is defined somewhere as your domain whereas it shouldn't
I am not sure, but I think domain was defined in /etc/hostname or /etc/HOSTNAME in the old Gentoo fashion.
Get rid of this file if it still exists
That would also explain why your prompt is cpqserver rather than bratchmshdsktop as set in your /etc/conf.d/hostname (unless you have tweaked your shell prompt)

2) There is a reply to the ping request. on interface lo... Good !
But nothing is caught at a upper level. With command
Code:
ifconfig -a
, is there an appropriate netmask for interface lo ? Is this interface up ?
Otherwise, check that /etc/init.d/net.eth0 is a symbolic link to /etc/init.d/net.lo and that both are started

3) reviewing this thread, it seems there is a mismatch between the IP of eth0 (0.4) and the hostname that has been set (bratchmshdsktop is 0.2 in /etc/hosts)

As a last resort, can you show the content of your /etc/resolv.conf in case of overriding rules ?

PS : are there some error messages on boot ?
PPS : try to resync and emerge baselayout package again if it was buggy at your last sync
_________________
-- Quxy
Back to top
View user's profile Send private message
l_bratch
Guru
Guru


Joined: 08 Feb 2005
Posts: 494
Location: Jersey

PostPosted: Tue Jan 31, 2006 9:59 pm    Post subject: Reply with quote

I meant that the ISP is answering the DNS request for "localhost" as "127.0.0.1", not that it was actually pinging the ISP.

1. I've removed /etc/hostname now.
2.
Code:
lo        Link encap:Local Loopback 
          inet addr:127.0.0.1  Mask:255.0.0.0
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:13455 errors:0 dropped:0 overruns:0 frame:0
          TX packets:13455 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:17054771 (16.2 Mb)  TX bytes:17054771 (16.2 Mb)
That seems to be working, and net.eth0 is indeed a symlink to net.lo, and both are started.
3. It would appear that I've been confusing myself with ssh sessions ;)
I've pasted a few things from a different machine on the same network by mistake, so anything I wrote as "bratchmshdsktop" should be "cpqserver" and "192.168.0.2" should be "192.168.0.4". I've checked the config files on both machines and they are the same apart from the names.

Here is my resolv.conf, it seems clean, and is the same as the other machine I'm using on the network:
Code:
cpqserver bratch # cat /etc/resolv.conf
nameserver 212.9.0.136


No errors on boot up, and I'll try resyncing and emerging baselayout now.
Back to top
View user's profile Send private message
turtles
Veteran
Veteran


Joined: 31 Dec 2004
Posts: 1698

PostPosted: Wed Feb 01, 2006 4:47 am    Post subject: Reply with quote

Quote:
DNSDOMAIN=""

I think you need to
Code:
nano -w /etc/conf.d/domainname
DNSDOMAIN="cpqserver"


If not make espresso, because you know the espresso maker will work.
:D
Back to top
View user's profile Send private message
l_bratch
Guru
Guru


Joined: 08 Feb 2005
Posts: 494
Location: Jersey

PostPosted: Wed Feb 01, 2006 8:11 am    Post subject: Reply with quote

Syncing and emerging baselayout didn't help at all (even after a reboot).

I set DNSDOMAIN as "cpqserver", but that didn't work either. In fact that added "domain cpqserver" onto the end of /etc/resolv.conf, which stopped localhost resolving at all.

It basically seems that /etc/hosts is being ignored...
Back to top
View user's profile Send private message
magic919
Advocate
Advocate


Joined: 17 Jun 2005
Posts: 2182
Location: Berkshire, UK

PostPosted: Wed Feb 01, 2006 9:15 am    Post subject: Reply with quote

How's your /etc/nsswitch.conf?
Back to top
View user's profile Send private message
l_bratch
Guru
Guru


Joined: 08 Feb 2005
Posts: 494
Location: Jersey

PostPosted: Wed Feb 01, 2006 12:12 pm    Post subject: Reply with quote

It's empty...

Should it be?
Back to top
View user's profile Send private message
magic919
Advocate
Advocate


Joined: 17 Jun 2005
Posts: 2182
Location: Berkshire, UK

PostPosted: Wed Feb 01, 2006 12:17 pm    Post subject: Reply with quote

I've check 3 of mine and all are not empty.

Code:

# /etc/nsswitch.conf:
# $Header: /var/cvsroot/gentoo-x86/sys-libs/glibc/files/nsswitch.conf,v 1.1 2005/05/17 00:52:41 vapier 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
Back to top
View user's profile Send private message
l_bratch
Guru
Guru


Joined: 08 Feb 2005
Posts: 494
Location: Jersey

PostPosted: Wed Feb 01, 2006 12:47 pm    Post subject: Reply with quote

Yes!

That was it, I filled in my /etc/nsswitch.conf with magic919's, chmodded it to 644, and finally the system is obeying /etc/hosts.

Thanks very much to all for the help, especially magic919 :D
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum