0

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)
drAlberT
  • 10,871
  • 7
  • 38
  • 52

6 Answers6

12

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.

minder
  • 709
  • 1
  • 5
  • 13
  • 1
    IIRC, on some versions of Windows (I think 95), the loopback interface was only available if you had a NIC (or modem, presumably) installed. – rmeador Sep 18 '09 at 15:41
  • 2
    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. – minder Sep 18 '09 at 15:46
  • 1
    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. – drAlberT Sep 18 '09 at 16:05
  • @AlberT: I'm confused about what you're saying. According to RFC 3330, any address in 127.x.x.x is the loopback interface. – rmeador Sep 18 '09 at 16:54
  • @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 – drAlberT Sep 18 '09 at 17:06
  • 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) – MDMarra Sep 18 '09 at 17:44
  • @AlbertT I think it's not a good idea to encourage the use non-RFC compliant network stack ;) – minder Sep 19 '09 at 08:10
  • Being pedantic about this _"...and is always available."_ Give this a try on Linux: `ifconfig lo down` – jscott Jun 02 '10 at 15:03
5
  • 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

drAlberT
  • 10,871
  • 7
  • 38
  • 52
  • 192.168.x.x is not a class B network, it's a class C... – Scott Lundberg Sep 18 '09 at 16:25
  • 1
    A C class is a.b.c.X, a B class is a.b.X.X – drAlberT Sep 18 '09 at 16:58
  • http://en.wikipedia.org/wiki/Classful_network#Classes – drAlberT Sep 18 '09 at 17:00
  • 3
    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. – mdpc Sep 18 '09 at 17:40
  • @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... – Scott Lundberg Sep 18 '09 at 19:15
  • 1
    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. – TrueDuality Sep 18 '09 at 19:35
  • I totally agree with @TrueDuality. – drAlberT Sep 20 '09 at 12:42
  • @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". – ktower Jun 02 '10 at 15:26
  • @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: http://www.faqs.org/rfcs/rfc1918.html#ixzz0rBiGVjkw – drAlberT Jun 18 '10 at 07:37
  • @AlberT: Keep reading into the next paragraph: "third block is a set of 256 contiguous class C network numbers", not a single "class B". There is a difference. /16 != Class B. Read more: http://www.faqs.org/rfcs/rfc1918.html#ixzz0rDTGiaTz – ktower Jun 18 '10 at 14:53
  • @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 :) – drAlberT Jun 19 '10 at 14:05
0

Yes, you can. In the PC world, 127.0.0.1 is the "loopback" address. On each network card, there is actually a circuit which "loops back" to the network interface, which allows you to test sending/receiving traffic without traffic actually leaving the card. It also allows you to connect to local network services without placing any load onto whatever switch you are connected to. In switches and routing equipment you can actually define the loopback address as any ip address you like, but the functionality is the same.

Matthew
  • 2,666
  • 8
  • 32
  • 50
0

Yes, pinging 127.0.0.1 works if you're not plugged in. Those addresses can be on the same network, but it depends on some other things on whether or not they actually are. They might be on different subnets. What are the subnet masks on the machines?

squillman
  • 37,618
  • 10
  • 90
  • 145
0

You can ping 127.0.0.1 if a computer is not connected to a network.

Machine A and B can both be on the same network, as their IPs are different. Assuming a 24-bit subnet mask, they are on different subnets though, so you will need routing between the subnets in order for them to communicate.

MDMarra
  • 100,183
  • 32
  • 195
  • 326
0

Kernel firewall packet filtering could be used to prevent ICMP packets from hitting loopback. In which case a ping would appear to fail (although the interface would still be up).

You could theoretically take it down, but then you would disable sockets. You'd have a seriously stripped down box that would boot up without loopback. It would resemble... MS-DOS!

dland
  • 123
  • 6