$_ CLI In Depth
Learning progress 0%
lesson networking sockets ssh

IP Addresses & Interfaces

3 min read Module 16: Networking Tools Updated Dec 5, 2026
Cheat Sheet
0:00 / 3:24

Interfaces are names for a path

An interface is a kernel object that sends and receives packets. Physical network cards, Wi-Fi adapters, virtual Ethernet pairs for containers, and the loopback device all appear as interfaces. Each one has a name, such as eth0 or wlan0, and a state. A packet that leaves the machine goes out through one interface, chosen by the routing table, which the next unit covers.

The loopback interface is special. It carries traffic from the machine to itself, so a program that connects to 127.0.0.1 never touches a cable. Because it always exists on Linux, it is the safest place to practice. The lab machine for this course has only loopback, which is enough to learn most of the tools in this module.

Reading addresses with ip

The compact view of every interface is ip -br addr. The brief flag prints one line per interface with its name, its state, and its addresses. The state UNKNOWN for loopback is normal, because loopback has no link light to report.

BASH1 lines
ip -br addr

In the lab, the output has one line for lo, with the state UNKNOWN and the address 127.0.0.1/8. The number after the slash is the prefix length. A /8 means the first eight bits identify the network, so the whole 127.x.x.x range belongs to the loopback network.

Understanding prefix length

An address with a prefix length, such as 192.168.1.20/24, names two things at once: the host address and the network it lives in. A /24 means the first 24 bits are the network and the last 8 bits identify the host, so 256 addresses share that network. The shorter the prefix, the larger the network. Two machines on the same network can reach each other directly. Machines on different networks need a router.

PrefixAddresses in the blockTypical use
/816,777,216The whole loopback range 127.0.0.0/8
/24256A small home or office network
/321A single host route

Showing one interface in detail

To see the full details of one interface, name it. The output includes the link layer address, the MTU, which is the largest packet the interface sends without splitting, and flags such as LOOPBACK and UP.

BASH1 lines
ip addr show lo

The flags field lists what the interface is doing. The mtu value on loopback is large, because nothing is transmitted over a wire. Use the same command with a real interface name on a normal machine to read its MTU and its addresses in one place.

Interfaces are up or down

An interface can be administratively down, which means it will not send or receive, or up. The ip tool changes that state with ip link set, which requires root privileges on most systems. Unprivileged users can read the state, which is what this unit asks you to do. A down interface still has its addresses, which can confuse people who expect an address to mean the interface works.

Note

The older ifconfig command is not installed in this lab image, and it is absent from many modern systems. The ip command does everything it did and more, so learn ip.

Hands-on: read the loopback

Run the two commands below. The first shows every interface in brief form, and the second shows the detail of loopback with its prefix. Compare the address in both outputs.

BASH2 lines
ip -br addr
ip -4 addr show lo

The lines show 127.0.0.1/8 in both places. The lab asks you to save the brief output for lo to a file, which practices reading one field from the command.

From a name to an address, then to a route

Visualizer

Two decisions come before any packet leaves: the name lookup picks an IP address, and the routing table picks the interface and next hop for that address.

1 / 4
getaddrinfo("localhost")
C library
name sources
address

A program asks the C library to turn a name into addresses, through getaddrinfo(). curl, ssh and ping all do this. No packet has been sent yet.

cat /etc/hosts; cat /etc/resolv.conf 2>/dev/null || echo "no resolv.conf"
Terminal lab · 2 steps · real Linux in your browser

Read the loopback interface

Save the brief listing of lo and extract its prefix from the address field.

01
Save the loopback listing
Create ipbrief.txt in /workspace with the brief address listing for the loopback interface only. Use the -br flag with the interface name lo: ``bash ip -br addr show lo > ipbrief.txt `` Open the file and find the address 127.0.0.1 with its prefix.
Show hint for step 1
The interface name comes after the subcommand. The file should contain one line that starts with lo.
02
Extract the IPv4 prefix
Write prefix.txt in /workspace containing only the IPv4 address of lo with its prefix length. Print the IPv4 address in one-line form with -o and -4, and keep the fourth field with awk: ``bash ip -o -4 addr show lo | awk '{print $4}' > prefix.txt ``
Show hint for step 2
The -o flag puts each address on one line. In that line, the fourth field is the address with its prefix.
Check yourself Question 1 of 4
Concept Check Brief interface listing recall

Which command prints one line per interface with its state and addresses?

Recap & Key Takeaways

An interface is the kernel attachment point for a network, and loopback lo always exists and carries traffic only to the machine itself.
ip -br addr prints one line per interface with its state and addresses, and ip addr show NAME prints the detail of one interface.
The number after the slash in an address is the prefix length, which says how many bits identify the network.
UNKNOWN state on loopback is normal, and an address on a down interface does not mean the interface can send traffic.
Was this lesson helpful? Spot an issue or have a suggestion? Let us know on GitHub.
Report an issue