shamelessly lifted from askubunto forum
The loopback device is a special, virtual network interface that your computer uses to communicate with itself. It is used mainly for diagnostics and troubleshooting, and to connect to servers running on the local machine.
This is important for troubleshooting (it can be compared to looking in a mirror). The loopback device is sometimes explained as purely a diagnostic tool. But it is also helpful when a server offering a resource you need is running on your own machine.
For example, if you run a web server, you have all your web documents and could examine them file by file. You may be able to load the files in your browser too, though with server-side active content, it won't work the way it does when someone accesses it normally.
So if you want to experience the same site others do, the best course is usually to connect to your own server. The loopback interface facilitates that.
For IPv4, the loopback interface is assigned all the IPs in the 127.0.0.0/8 address block. That is, 127.0.0.1 through 127.255.255.254 all represent your computer. For most purposes, though, it is only necessary to use one IP address, and that is 127.0.0.1. This IP has the hostname of localhost mapped to it.
Thus, to log in as bob via SSH to the SSH server running on your own machine, you would use:
ssh bob@localhost
Like other network adapters, the loopback device shows up in the output of ifconfig. Its name is lo.
ek@Del:~$ ifconfig lo lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:50121 errors:0 dropped:0 overruns:0 frame:0 TX packets:50121 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:4381349 (4.3 MB) TX bytes:4381349 (4.3 MB)
If you come from a Windows background, you might expect loopback to itself be a synonym of localhost (and thus to be able to ping loopback, connect to servers on loopback, and so forth). That behavior is peculiar to Windows.
But you can add any name including loopback to your /etc/hosts file, with 127.0.0.1 as its address, and it will act like localhost.