Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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)
share|improve this question

migrated from stackoverflow.com Sep 18 '09 at 15:30

This question came from our site for professional and enthusiast programmers.

6 Answers 6

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.

share|improve this answer
  • 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|improve this answer
    
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 –  AlberT Sep 18 '09 at 16:58
    
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
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

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!

share|improve this answer

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.

share|improve this answer
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. –  AlberT 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 –  AlberT Sep 18 '09 at 17:06

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.

share|improve this answer
    
There is no reason to assume a mask of 24 bits. –  bortzmeyer Sep 21 '09 at 20:11
    
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. –  MDMarra Sep 21 '09 at 20:34

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?

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.