LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 10-15-2004, 05:51 AM   #1
Mr. Gone
LQ Newbie
 
Registered: Mar 2004
Posts: 29

Rep: Reputation: 15
Can't ping localhost (/etc/hosts and DNS are OK)


By chance I found that I couldn't browse or ping to localhost. To read CHM files I use 'archmage', and after running it you have to point your browser to localhost:number_of_port_chosen. Previously I never had any problem with it, and I always used localhost (for example, localhost:25471), but today it told me "Unknown host locahost". Later I found out that I could access the CHM -"massaged" by 'archmage'- if instead of localhost I used 127.0.0.1.

After that I tried to ping localhost, to no avail:

Code:
ping -c 5 localhost 
PING localhost (127.0.0.1) 56(84) bytes of data. 

--- localhost ping statistics --- 
5 packets transmitted, 0 received, 100% packet loss, time 4012ms
Then I also tried to ping 127.0.0.1, with the same result:

Code:
ping -c 5 127.0.0.1
PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data. 

--- 127.0.0.1 ping statistics --- 
5 packets transmitted, 0 received, 100% packet loss, time 4011ms
However, everything seems to be right.

Code:
$ /sbin/ifconfig

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:32581 errors:0 dropped:0 overruns:0 frame:0
          TX packets:32581 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 
          RX bytes:6119744 (5.8 Mb)  TX bytes:6119744 (5.8 Mb)


$ less /etc/hosts

127.0.0.1               localhost


$ less /etc/sysconfig/network-scripts/ifcfg-lo

DEVICE=lo
IPADDR=127.0.0.1
NETMASK=255.0.0.0
NETWORK=127.0.0.0
# If you're having problems with gated making 127.0.0.0/8 a martian,
# you can change this to something else (255.255.255.255, for example)
BROADCAST=127.255.255.255
ONBOOT=yes
NAME=loopback
My Internet connection works as usual, and other than the scenarios described above everything seems to work OK. DNS works normally, too (at least I think), and /etc/resolv.conf contains the two nameservers given by my ISP. I can browse the web normally.

I don't know if this will have anything to do, but recently I changed my DSL modem (USB) and I realised that it uses 'zcip' (Zeroconf) during its initialization. As 'zcip' assigns IP addresses without manual assignment (perhaps to the virtual eth interface, though I'm not sure of that), I've thought that maybe it could have anything to do with the problem.

Any suggestion will be greatly appreciated.

Last edited by Mr. Gone; 10-15-2004 at 05:54 AM.
 
Old 10-15-2004, 01:06 PM   #2
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Can you post the output from:
route -n
iptables -nL
 
Old 10-16-2004, 09:14 AM   #3
Mr. Gone
LQ Newbie
 
Registered: Mar 2004
Posts: 29

Original Poster
Rep: Reputation: 15
Thanks for replying, Dave.

Here's the output:

Code:
$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
###.###.###.##  0.0.0.0         255.255.255.0   U     0      0        0 eth1
127.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 lo
0.0.0.0        ###.###.###.##   0.0.0.0         UG    0      0        0 eth1

Code:
$ iptables -nL
Chain INPUT (policy DROP)
target     prot opt source               destination         
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0          
DROP       all  --  ###.###.###.###      0.0.0.0/0          
DROP       all  --  10.0.0.0/8           0.0.0.0/0          
DROP       all  --  127.0.0.0/8          0.0.0.0/0          
DROP       all  --  169.254.0.0/16       0.0.0.0/0          
DROP       all  --  172.16.0.0/12        0.0.0.0/0          
DROP       all  --  192.168.0.0/16       0.0.0.0/0          
DROP       all  --  224.0.0.0/4          0.0.0.0/0          
DROP       all  --  240.0.0.0/8          0.0.0.0/0          
DROP       all  --  0.0.0.0/8            0.0.0.0/0          
DROP       all  --  255.255.255.255      0.0.0.0/0          
LOG        udp  --  0.0.0.0/0           ###.###.###.###     udp spt:!53 LOG flags 0 level 4 
DROP       udp  --  0.0.0.0/0           ###.###.###.###     udp spt:!53 
LOG        tcp  --  0.0.0.0/0           ###.###.###.###     tcp dpts:!2234:2239 flags:0x16/0x02 LOG flags 0 level 4 
ACCEPT     udp  --  [DNS nameserver]     0.0.0.0/0          udp spt:53 
ACCEPT     udp  --  [DNS nameserver]     0.0.0.0/0          udp spt:53 
DROP       tcp  --  0.0.0.0/0            0.0.0.0/0          tcp flags:0x16/0x02 
DROP       udp  --  0.0.0.0/0            0.0.0.0/0          
ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0          state RELATED,ESTABLISHED 
DROP       all  --  0.0.0.0/0            0.0.0.0/0          state INVALID
[###.###.###.### is my IP. It's static and I don't feel like airing it...]

The rule related to 127.0.0.1/8 is:

Code:
iptables -A INPUT -i eth1 -s 127.0.0.0/8 -j DROP
So it affects the 'eth1' interface and shouldn't conflict with loopback. As you know, it is to avoid spoofed packets pretending to come from localhost.

I have used this same 'iptables' rules for a long time and they didn't seem to conflict before. But as I said I changed my modem and the new one works in a different way. The old one used 'atm' and created an interface 'atm0'; the new one creates a virtual eth interface and is launched as 'eth1'. Don't know if this will be related, though, but I explain it just in case.

Thanks again for the help.
 
Old 10-16-2004, 09:21 AM   #4
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Perhaps you are not replying to icmp packets, do you get any 1s from running:
grep "" /proc/sys/net/ipv4/icmp_echo_ignore_*

If so then just echo a 0 into that file.
 
Old 10-16-2004, 10:43 AM   #5
Mr. Gone
LQ Newbie
 
Registered: Mar 2004
Posts: 29

Original Poster
Rep: Reputation: 15
Yes, after echoing "0" in /proc/sys/net/ipv4/icmp_echo_ignore_all I could ping localhost. My fault, as I didn't remember I have these two lines in my 'iptables' config:

echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts
echo "1" > /proc/sys/net/ipv4/icmp_echo_ignore_all

However, echoing "0" in these two files didn't solve the browser problem, as it keeps saying "Unknown host locahost" when pointing it to localhost:[port#] to read a CHM file processed by 'archmage'. Anyway, I can read them using 127.0.0.1:[port#], but I'd like to know why localhost worked before and it doesn't work now (not a direct question, just thinking aloud)...

Thanks again for your help.
 
Old 10-16-2004, 10:50 AM   #6
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
What do your /etc/hosts and /etc/host.conf files contain?
 
Old 10-16-2004, 11:18 AM   #7
Mr. Gone
LQ Newbie
 
Registered: Mar 2004
Posts: 29

Original Poster
Rep: Reputation: 15
$ cat /etc/hosts
127.0.0.1 localhost

$ cat /etc/host.conf
order hosts,bind
multi on

Thanks for keep on trying.
 
Old 10-16-2004, 12:54 PM   #8
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
That does seem odd, I can't think why a browser would do that. Does it happen with all browsers?
 
Old 10-16-2004, 02:51 PM   #9
Mr. Gone
LQ Newbie
 
Registered: Mar 2004
Posts: 29

Original Poster
Rep: Reputation: 15
Yes; it happened with Konqueror, and then I tried with Mozilla. Mozilla brought me to a brazilian page called localhost.com.br.

I didn't think to try with a third one until now, when I read your suggestion. So I tried with Firefox and found that it works. Then I tried with w3m and it worked as well.

The sequence is more or less this: when I saw that Mozilla didn't work (for different reasons, as I know now), I tried to ping localhost. This of course didn't work because of the 'iptables' rule, and made me relate two unrelated things. So something in Konqueror causes to fail when directed to localhost; weird, though, because it worked before. Anyway, I can live with that. Guess I haven't been very empirical this time.

The worst thing is that I've wasted your time with this thread. I'm really sorry, and thanks again for the help.
 
Old 10-16-2004, 03:05 PM   #10
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
No problem, don't worry about it. Perhaps konqueror is caching the information somehow.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Strange Ping Issue - Can't ping localhost but can ping others on LAN code_slinger Linux - Networking 15 03-30-2015 02:39 PM
Can't ping localhost (ping: sendto: Operation not permitted) mentor99us Linux - Networking 7 09-05-2012 02:11 PM
dhcp client can't ping gateway but can ping other local hosts dirty_forks Linux - Networking 7 10-08-2004 10:54 AM
MDK 9.2, Can't ping localhost but can ping outside world? JohnLocke Linux - Networking 2 07-01-2004 05:59 PM
dns requests from localhost to localhost keex Linux - Networking 2 11-13-2003 01:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 03:17 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration