Read a sample: 1. What an IP Address Can Tell You
When someone asks, “What is your Linux machine’s IP address?” the question sounds as though it should have one short answer. In practice, the useful answer begins with another question: Which address, and for what purpose?
A laptop may have an address on its wireless connection, another on a VPN, and several IPv6 addresses on the same interface. It also has a loopback address for communicating with itself. A server may have addresses on multiple network interfaces, while a container may see a different network environment from the Linux host running it.
None of this means finding an address has to be difficult. It means an address becomes useful evidence when you know where you found it and what you are trying to explain.
This chapter gives you the working model for the rest of the book. You will meet hosts, interfaces, addresses, and routes; distinguish an address from the process that configured it; and prepare a read-only practice environment. By the end, you will be ready to examine your own system without assuming that the first number you see answers every networking question.
Suppose a help-desk ticket says, “Please send me the IP address of your computer.” Before choosing a command, consider what the requester needs.
If a colleague is troubleshooting access to a service on your local network, the address assigned to your active network interface may be relevant. If a website is blocking your connection, the address that website sees may be different from the one listed on your Linux interface. If you are investigating why an address changed after a reboot, you need more than the address itself: you need evidence about how it was configured.
These are related but distinct tasks:
- Inventory: What addresses are currently assigned, and to which interfaces?
- Routing: Which interface and route would Linux choose for a particular destination?
- Origin: What configuration mechanism supplied or created an address?
- External observation: What source address does a particular remote service see?
A command can answer part of one question without answering the others. An address listing, for example, can show that an interface has an IPv4 address. It does not necessarily establish whether that address was configured manually, obtained through DHCP, or placed there by another network-management process.
Throughout this book, tracing an address’s origin means investigating how the local address came to be configured. It does not mean identifying a person, proving a physical location, or tracing every network device between two hosts.
A host is a device or networked system that can send or receive traffic. Your Linux laptop can be a host. So can a server, a virtual machine, or a container with its own network environment.
An interface is a point at which the system handles network traffic. You can think of it as a connection point in Linux’s networking model. Some interfaces correspond to physical hardware, such as an Ethernet adapter or a wireless device. Others are created in software for purposes such as loopback communication, virtual networking, or tunneling.
Interface names vary. You might see names such as lo, enp1s0, or wlan0, but your system may use different names. Do not assume that an example name exists on your machine or that a name alone tells you everything about an interface.
The loopback interface, commonly named lo, is especially useful to recognize. Traffic sent to a loopback address stays within the local host’s networking environment. The familiar IPv4 loopback address is 127.0.0.1; IPv6 uses ::1. These addresses are real parts of the system’s network configuration, but they are not normally the addresses you would give another computer to reach your machine.
An interface can exist without having a usable address for the task you have in mind. It might be disconnected, administratively disabled, awaiting configuration, or intended for a different kind of traffic. Conversely, one interface can have several addresses. Counting interfaces is therefore not the same as counting addresses or working network connections.
An IP address is a numeric identifier used in IP communication. Linux supports both major versions in common use: IPv4 and IPv6.
IPv4 addresses are written as four decimal numbers separated by periods, such as 192.0.2.10. IPv6 addresses use hexadecimal notation and colons, such as 2001:db8::10. These two examples come from ranges reserved for documentation; they are used here to illustrate notation, not as addresses you should expect to reach on the public internet.
An address shown on an interface is often followed by a slash and a number:
text
192.0.2.10/24
2001:db8::10/64
The number after the slash is the prefix length. It describes how many leading bits belong to the network prefix in that address notation. For now, the practical point is that the address and prefix belong together in an inventory. Recording only 192.0.2.10 loses information that helps explain how the system understands the surrounding network.
Later chapters work through IPv4 and IPv6 prefixes in detail. You do not need to calculate subnets to begin. When inspecting your system, simply preserve the address, prefix length, and interface name as a set.
Addresses also have different intended uses. Some are meant for communication within a limited context, while others may be usable more broadly. For example, an IPv6 link-local address is associated with a particular link, and a loopback address refers back to the local host. A local or private address should not automatically be treated as the public-facing…