Results 1 to 10 of 10

Thread: Can't ping localhost when not connected to network

  1. #1
    Join Date
    Oct 2009
    Beans
    4
    Distro
    Ubuntu 10.04 Lucid Lynx

    Can't ping localhost when not connected to network

    Hi there,

    As the title says, I'm having trouble pinging localhost, specifically, pinging localhost when I'm not connected to a network.

    When I try it keeps telling me the operation is not permitted:
    Code:
    matt@mubuntu:~$ ping localhost
    PING localhost (127.0.0.1) 56(84) bytes of data.
    ping: sendmsg: Operation not permitted
    ping: sendmsg: Operation not permitted
    But if I connect to the network, start pinging then disconnect it continues pinging.

    Google seems to think it could be something to do with my iptables setup:
    Code:
    matt@mubuntu:~$ sudo iptables -L
    Chain INPUT (policy ACCEPT)
    target     prot opt source               destination         
    
    Chain FORWARD (policy ACCEPT)
    target     prot opt source               destination         
    ACCEPT     all  --  anywhere             anywhere            ctstate RELATED,ESTABLISHED 
    
    Chain OUTPUT (policy ACCEPT)
    target     prot opt source               destination
    Or my routes:

    When connected to network
    Code:
    matt@mubuntu:~$ route -n
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    192.168.1.0     0.0.0.0         255.255.255.0   U     1      0        0 eth1
    169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth1
    127.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 lo
    0.0.0.0         192.168.1.1     0.0.0.0         UG    0      0        0 eth1

    When not connected to network
    Code:
    matt@mubuntu:~$ route -n
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    127.0.0.0       0.0.0.0         255.0.0.0       U     0      0        0 lo
    But as far as I can tell there isn't anything in there which would stop me connecting to the localhost (I also can't connect to my local apache instance when offline)...

    I'm at a loss as to what to do, does anyone have any ideas as to what I'm doing wrong.

    (It's worth mentioning that a couple of weeks ago I had the pc setup to share it's internet connection with a laptop, ala this guide, however I've since disabled the iptables rules and disabled ip forwarding.)
    Last edited by DanDare; July 8th, 2010 at 02:53 PM.

  2. #2
    Join Date
    Oct 2009
    Beans
    4
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Can't ping localhost when not connected to network

    Ok, turning off iptables got it working but I have no idea why...

    Is there a reason behind it blocking access to localhost only when disconnected from the network and is there some way to fix this?

  3. #3
    Join Date
    Jan 2006
    Location
    Not heaven... Iowa
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Can't ping localhost when not connected to network

    Apparently, I'm already off-base, but...
    What is in your /etc/hosts file?
    Linux User #415691 Ubuntu User #8629
    Iowa Team (LoCo): [Wiki] [Launchpad]
    IRC channel: #ubuntu-us-ia on irc.freenode.net

  4. #4
    Join Date
    Oct 2009
    Beans
    4
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Can't ping localhost when not connected to network

    Hi Iowan,

    Not quite sure how but since iptables was disabled everything's been working fine, even when iptables was re-enabled.

    It seems very odd...

    Thanks for your help anyway!

  5. #5
    Join Date
    Jan 2006
    Location
    Not heaven... Iowa
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: Can't ping localhost when not connected to network

    Odd, indeed...
    Give it a couple of days to see if it stays working before marking the thread [SOLVED].
    Linux User #415691 Ubuntu User #8629
    Iowa Team (LoCo): [Wiki] [Launchpad]
    IRC channel: #ubuntu-us-ia on irc.freenode.net

  6. #6
    Join Date
    Aug 2006
    Beans
    Hidden!

    Re: Can't ping localhost when not connected to network

    i have the same problem but it didn't get resolved by switching off iptables.

    as soon as i disconnect from internet (with gui networkmanager), both "ping localhost" and "ping 127.0.0.1" return:

    ping: sendmsg: Operation not permitted

    i switched off iptables, "iptables -L" gives:

    Code:
    Chain INPUT (policy ACCEPT)
    
    target prot opt source destination
    
    Chain FORWARD (policy ACCEPT)
    
    target prot opt source destination
    
    Chain OUTPUT (policy ACCEPT)
    
    target prot opt source destination
    /etc/hosts contents:

    Code:
    127.0.0.1	localhost
    127.0.0.1	glocalhost
    127.0.1.1	ubuntu.ubuntu-domain	ubuntu
    route -n with network on

    Code:
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
    192.168.1.0     0.0.0.0         255.255.255.0   U     2      0        0 eth1
    169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth1
    0.0.0.0         192.168.1.254   0.0.0.0         UG    0      0        0 eth1
    route -n with network off is empty:

    Code:
    Kernel IP routing table
    Destination     Gateway         Genmask         Flags Metric Ref    Use Iface

  7. #7
    Join Date
    Aug 2006
    Beans
    Hidden!

    Re: Can't ping localhost when not connected to network

    oh, right, i don't have loopback interface

    it's described in /etc/network/interfaces though

    Code:
    auto lo
    iface lo inet loopback
    
    auto eth1
    iface eth1 inet dhcp
    what should i change to turn it on?

  8. #8
    Join Date
    Aug 2006
    Beans
    Hidden!

    Re: Can't ping localhost when not connected to network

    ps.

    Code:
    sudo ifconfig lo up
    doesn't change anything

  9. #9
    Join Date
    Aug 2006
    Beans
    Hidden!

    Re: Can't ping localhost when not connected to network

    help anyone?

    i am a web developer and live in country where electricity often goes off, so i cannot develop when i don't have wireless
    because localhost is inaccessible and all my local servers stop being accessible(i have apache and nginx)

  10. #10
    Join Date
    Aug 2006
    Beans
    Hidden!

    Re: Can't ping localhost when not connected to network

    help anyone?
    it's bigger than it seems - i am a web developer and live in country where electricity often goes off, so currently i cannot develop when i don't have wireless because localhost is inaccessible and all my local servers stop being accessible(i have apache and nginx and rack)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •