What is a loopback interface?

Asked

Viewed 1,768 times

6

I was going through socket connection issues on my server:

Causing the error [could not bind to "tcp://127.0.0.1:8843". Cannot assign request Adress]?

I managed to solve the problem. The technician told me that the problem was that "the loopback interface was stopped and had to be started".

Like I said, I suck at technicalities.

So I’d like to understand what a loopback interface is.

And why, when it stopped running, it caused any code that used socket connections with 127.0.0.1 stopped working, being accepted only 0.0.0.0?

  • 3

    Who’s to say the guy didn’t screw you up? P

  • @rray do not put me in doubt, friend. Actually, after I talked to him: "Is it only working with 0.0.0.0, with localhost not working?" , he made the expression: "Wow, your loopback isn’t running". And then it worked :D

1 answer

3

The loopback interface is a virtual network interface used basically for two purposes:

  • Diagnosis;
  • For developing and testing systems that require a network interface with an IP (Webservers, etc).

On a Linux system, type ifconfig to check your loopback interface:

ifconfig


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:65536  Metric:1
          RX packets:353933 errors:0 dropped:0 overruns:0 frame:0
          TX packets:353933 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:584828381 (584.8 MB)  TX bytes:584828381 (584.8 MB)

Because it is a network interface it is possible to stop it:

sudo ifconfig lo down

Just like lifting it:

sudo ifconfig lo up

The diagnostic part can be used, for example, to check if your machine has ssh server active. Try this:

ssh user@localhost

If the machine in question is with an SSH server listening on port 22, then the machine itself will be accessed from it via SSH (see loopback happening). :-)

In the development part of systems, the loopback interface is widely used when you want to develop and run the server (web, tcp, etc.) on the machine itself. Example of an address when developing Java + Tomcat: http://localhost:8080/App or http://127.0.0.1:8080/App

It is interesting to note that the range of Ips associated with this interface is the 127.0.0.0/8. Therefore, you can drip any of the addresses ranging from 127.0.0.1 until 127.255.255.254 that this interface will answer. However, the most famous is the first, 127.0.0.1. It is usually in this IP that is associated the famous hostname localhost.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.