Can I ping 127.0.0.1 if my computer isn't connected to a network?

11,675

Solution 1

Yes, 127.0.0.1 is called loopback network and is always available. This address points to the machine itself.

EDIT: To answer the second part of the question: Yes, machines A and B can be on the same network (but NOT the same as 127.0.0.1, while loopback is virtual) if the netmask is set properly. Use IP calculator to get what you need.

Solution 2

  • yes of course, 127.0.0.1 is always available. It is the "localhost", pointing to the machine itself without going to a real net. It is the address of the loopback device and it is present even if no net card is installed (on every modern OS at least).

  • 192.168.x.x is a set of 256 C classes for internal use (see RFC1918) so you can have 65k hosts (as if it would had been a B class). So your machines can stay on the same net and see each others, pay attention to have the right netmask!

    If you have a netmask 255.255.0.0 they are on the same net, if you have 255.255.255.0 they don't

Share:
11,675
Sandokas
Author by

Sandokas

Lots of info about me is on my LinkedIn profile and links therefrom. My social accounts: Twitter: @drAlberT75 GitHub: drAlberT and faktiva organization

Updated on September 17, 2022

Comments

  • Sandokas
    Sandokas over 1 year

    Does pinging 127.0.0.1 work on your machine if it's not on the network?

    Can these two machine be on the same network?

    machine A (192.168.173.11) 
    machine B (192.168.163.11)
    
  • rmeador
    rmeador over 14 years
    IIRC, on some versions of Windows (I think 95), the loopback interface was only available if you had a NIC (or modem, presumably) installed.
  • minder
    minder over 14 years
    Yeah, but let's say we don't count ancient systems ;) If he has a network stack installed (required to set machine's IP), he has the loopback interface.
  • Sandokas
    Sandokas over 14 years
    127.0.0.1 is an HOST, not a network. So A and B can't stay on the same 127.0.0.1 becouse it is an host IP, not becouse it is not a real IP. If a and B are given 127.0.0.3 and 127.0.0.4 they could see each others.
  • Scott Lundberg
    Scott Lundberg over 14 years
    192.168.x.x is not a class B network, it's a class C...
  • rmeador
    rmeador over 14 years
    @AlberT: I'm confused about what you're saying. According to RFC 3330, any address in 127.x.x.x is the loopback interface.
  • Sandokas
    Sandokas over 14 years
    A C class is a.b.c.X, a B class is a.b.X.X
  • Sandokas
    Sandokas over 14 years
  • Sandokas
    Sandokas over 14 years
    @meador, you are right this class is not routable. But not every net stack accomplish the RFC, so is possible to have packets directed to 127.0.0.3 to be routed to a physical interface. My poit was to undeline that 127.0.0.1 is an host, not a net... two hosts can't comunicate having the same IP, even if the IP is not RFC3330 or RFC1918. This was my point
  • mdpc
    mdpc over 14 years
    I thought that there is now no such thing as network classes. The old style 'B class' networks are being distributed as much smaller subset these days. Network classes are a thing of the past.
  • MDMarra
    MDMarra over 14 years
    AlberT - I'm curious, in what situation is 127.x.x.x routable? I've never seen this (but again there are plenty of situations I haven't seen)
  • Scott Lundberg
    Scott Lundberg over 14 years
    @AlberT: you are correct if you look at just the subnet mask, but anyone can use a classless subnet mask. If you look further down on the wiki post, you will see that Class C starts at 192.0.0.0 regardless of the subnet mask...
  • abby
    abby over 14 years
    That only defines the reserved range for that block. "Classes" are a way to define which super block a particular subnet belongs to. This is entirely dependent on the netmask in use. 255.0.0.0 is a Class A, 255.255.0.0 is a Class B, and 255.255.255.0 is a Class C. People commonly refer to blocks that they have been assigned in these classes as well even if they have broken them down further.
  • minder
    minder over 14 years
    @AlbertT I think it's not a good idea to encourage the use non-RFC compliant network stack ;)
  • bortzmeyer
    bortzmeyer over 14 years
    There is no reason to assume a mask of 24 bits.
  • MDMarra
    MDMarra over 14 years
    The only way to answer the question as stated is to assume certain things about the setup. Seeing as /24 is the most common it is what I assumed.
  • jscott
    jscott almost 14 years
    Being pedantic about this "...and is always available." Give this a try on Linux: ifconfig lo down
  • ktower
    ktower almost 14 years
    @AlberT: Read your own sources. Using the old class mentality, 192.168.x.x is considered Class C space (leading bits of 110), and while a /16 block ("class B") is reserved, RFC 1918 states it is "a set of 256 contiguous class C network numbers".
  • Sandokas
    Sandokas almost 14 years
    @ktower: as far as I can read in RFC1918 it says: 3. Private Address Space The Internet Assigned Numbers Authority (IANA) has reserved the following three blocks of the IP address space for private internets: 10.0.0.0 - 10.255.255.255 (10/8 prefix) 172.16.0.0 - 172.31.255.255 (172.16/12 prefix) 192.168.0.0 - 192.168.255.255 (192.168/16 prefix) Read more: faqs.org/rfcs/rfc1918.html#ixzz0rBiGVjkw
  • Sandokas
    Sandokas almost 14 years
    @ktower I got your point right now. Sorry did not understood what you are referring to, yes of course you are right, 192.168.y.x is technically not a single C class, but a set of "y" (say 256) C classes. Got you point and agreed :)