tags:

views:

260

answers:

7

What I want to know is if I were execute something like ping localhost would the packets be redirected by the operating system and go directly to the destination port or would the packets go out on the network to the nearest router or switch which then bounces them back to your computer?

+5  A: 

No packets will hit the network. Unplug your network cable and try it!

RichieHindle
IIRC, there was an older version of Windows where you didn't have a loopback interface if you didn't have a network interface. It wouldn't work until your computer had been plugged into a network at least temporarily. or something like that. silly windows.
rmeador
I think Win 95 behaved that horrible way until you defined some kind of network interface. A dial-up adapter you never used was good enough.
Joshua
A: 

No, it's called loopback for a reason. IIRC, packets to 127.0.0.1 aren't allowed "outside" the computer.

Marcus Lindblom
A: 

No, the packets will not go to the network.

Nathaniel Flath
+1  A: 

The packets will stay on your machine.

The name 'localhost' is an alias from 127.0.0.1 in the hosts file, if you edit the hosts file (UNIX: /etc/hosts Windows: C:\windows\system32\drivers\etc\hosts) and change localhost for any other word then you'll access your local host using that other word.

The address 127.0.0.1 is a loopback address, it is defined in RFC3330

victor hugo
+3  A: 

Any packets sent to an IP address attached to a local interface do not go out of your host. 127.0.0.1 is not special in this regard. Both ping 127.0.0.1 and ping 192.168.1.44 will transmit and receive ICMP packets over the "loopback network device". You can confirm this by unplugging your Ethernet cable and observing the TX and RX counters.

$ /sbin/ifconfig
eth0      Link encap:Ethernet
          inet addr:192.168.1.44  Bcast:192.168.3.255  Mask:255.255.252.0

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          RX packets:992670 errors:0 dropped:0 overruns:0 frame:0
          TX packets:992670 errors:0 dropped:0 overruns:0 carrier:0
sigjuice
+1  A: 

That depends on name resolution. Try that ping after # echo "69.59.196.211 localhost" > /etc/hosts.

Nikolai N Fetissov
A: 

no it will not work but i dont know the reason as to why so would you mind to tell me the reason now?