Linux Labs

Networking / Stage 1 of 14

Interfaces, addresses and subnets

Not running Starting usually ~20 s
Leave the lesson

Step 2 of 8 · on a machine · 5 min

An interface and its addresses

An interface that is up and a correct address are two different things, and ip shows both on one line.

A network interface is the device the kernel sends and receives packets through: a network card or a virtual device. On the client it is lab0. The @if2 suffix means lab0 has a paired end on the other side.

An IP address is assigned to an interface, and other hosts find the machine by it. One interface may have several addresses, or none at all.

ip -brief link lists the interfaces and their state, and ip -brief address shows the same together with the addresses. The -4 option keeps only IPv4 addresses, four numbers separated by dots. Without it you also see IPv6 addresses such as ::1. Look at the machine itself:

bash
ip -brief link
ip -brief address

The machine has one interface, lo, with the addresses 127.0.0.1/8 and ::1/128. This is loopback: the machine uses this address to talk to itself, and nothing leaves through it. Every machine has its own 127.0.0.1, so the address is no use to another host.

Check yourself 1 question

On the server, curl http://127.0.0.1/ prints the site's page. A colleague opens http://127.0.0.1/ in the browser on their own computer. What will they see?

  • The subnet has nothing to do with it: 127.0.0.1 lives on lo and never leaves the machine. A neighbour needs the address of the server's network interface.

  • Every machine has its own 127.0.0.1: the colleague's browser will talk to their own computer. The server is reached at the address of its network interface.

  • A browser opens 127.0.0.1 like any address; it is simply its own machine. On the server, curl http://127.0.0.1/ works the same way.

127.0.0.1 is the loopback address: every machine answers it by itself. To reach the server, the colleague needs the address of the server's network interface.

Key points

  • An address is assigned to an interface: ip -brief address shows the name, state and addresses on one line.
  • -4 keeps only IPv4 addresses in the output of ip.
  • 127.0.0.1 on lo is the machine itself; the address is no use to other hosts.
Ubuntu 24.04
Loading…