Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Suppose I have a web server and my IP is a.b.c.d (not the loop back address). When I launch the browser locally and point at a.b.c.d, what actually happens at packets level? Do the ip packets goes out of the machine to a router/switch and travel back or is the system (which happen to be Linux btw) smart enough to direct the packets to the local machine itself?

lang2

share|improve this question
    
You can do traceroute a.b.c.d to see. It probably depends on your system's configuration. –  user55325 Dec 19 '12 at 15:26

2 Answers 2

up vote 2 down vote accepted

A switch won't send packets back to their source, and routers are typically connected through switches. So it would be disastrous if the machine just assumed something would send the packets back to it. They're never put on the wire.

On an Ethernet network, each unicast packet has an Ethernet hardware address of the destination machine the packet is being sent to on that network. There's no reason a machine would ever send out a packet with its own address as the destination, and the results of doing so would be unpredictable -- some networks would return it, some wouldn't.

(The above assumes the IP address is part of an Ethernet or WiFi network, which is the most common arrangement. The details are a bit different if it's not, but the OS will still internally loop the packet back because that's how IP stacks work.)

share|improve this answer
    
So the point of loopback is only where there is no external connectivities? –  lang2 Dec 19 '12 at 15:44
1  
@lang2 The point of loopback is for testing that you have a working TCP/IP stack, and to make it easy to host a client and a server on the same computer. –  David Dec 19 '12 at 15:51
    
Loopback is useful in all cases where you need to connect to something local, whether you do or don't also have external connectivity. –  David Schwartz Dec 19 '12 at 17:42

If you unplug the network cable, you'll see that you can still open the browser and connect to your local web server through the local IP.

share|improve this answer

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.