What Is an IP Address?
This piece is for anyone who runs a server, debugs a network, or has ever wondered why the same machine shows one address to you and a different one to the outside world. We'll cover the structure of IPv4 and IPv6, the difference between local and public addresses, static versus dynamic assignment, and how to check all of it from the command line.
Requirements
You need a Linux system with `iproute2` installed. That package ships by default on Debian 12, Ubuntu 22.04 and later, RHEL 9, and Fedora 39. If `ip` is missing, install it:```bash sudo apt install iproute2 ```
On RHEL-based systems:
```bash sudo dnf install iproute ```
You also want `curl` for the public-address checks later in this article. No root is required for the read-only commands. You only need `sudo` if you want to change an address, and we won't do that here.
What an IP address actually is
An IP address is a unique number that identifies a device on a network. IP stands for Internet Protocol, and the address is the part of that protocol that says where a packet should go.Every device on a network gets one: a laptop, a phone, a printer, a server. Without it, the device cannot be addressed. The comparison with a house without a street address holds up better than most analogies — mail without an address doesn't arrive, and a packet without a destination address doesn't either.
The address is assigned automatically, usually by a router or by your internet provider. You rarely type one in by hand. But the assignment is not magic, and understanding who hands out what, and why, is the difference between debugging a network in five minutes and debugging it in five hours.
IPv4: 32 bits, four numbers, almost exhausted
IPv4 is the version most people mean when they say "IP address." It is a 32-bit value, written as four numbers separated by dots:``` 192.168.1.100 ```
Each of those four numbers runs from 0 to 255. That gives a theoretical range from `0.0.0.0` to `255.255.255.255`, and roughly 4.3 billion unique addresses.
That sounds like a lot until you count devices. Phones, laptops, servers, smart TVs, thermostats, and every container in a Kubernetes cluster wants an address. The pool ran dry at the top level years ago, which is why the regional internet registries now hand out IPv4 space from a waiting list, if at all.
Behind the dotted notation, the address is still 32 binary digits. The dots exist because humans read decimal better than they read `11000000.10101000.00000001.01100100`. The machine doesn't care about the formatting.
IPv6: 128 bits, and enough room
IPv6 fixes the exhaustion problem by making addresses 128 bits long. That is not four times as many addresses; it is 2^96 times as many. The number is large enough that assigning one to every atom on the planet's surface would not exhaust it.IPv6 addresses are written in hexadecimal with colons as separators:
``` 2001:0db8:85a3:0000:0000:8a2e:0370:7334 ```
That notation is harder to read than IPv4, and it is harder to type. The tradeoff is deliberate: the address space is large enough that you never have to ration it, and the protocol was designed with routing efficiency in mind from the start.
The first specification for IPv6, RFC 1884, dates from December 1995. It was later revised and superseded by RFC 4291, published on 17 February 2006. Those RFCs are the technical documents that define how the protocol works.
IPv6 has existed for almost thirty years and IPv4 is still everywhere. Most systems run both at once, a setup called dual-stack. The migration is slow because every router, server, and piece of software in the path has to support IPv6 before you can turn IPv4 off. Large providers and cloud platforms have moved faster, mostly because they ran out of IPv4 addresses and had no choice.
Static versus dynamic addresses
A static IP address stays the same. Servers use them, because a web server that changes address every time it reboots is a web server nobody can find.A dynamic IP address changes each time the device joins the network. Home connections work this way. The provider assigns a temporary address from a pool, and the assignment happens through DHCP, the Dynamic Host Configuration Protocol.
For a home connection, dynamic is fine. For anything you need to reach reliably — a mail server, a VPN endpoint, a monitoring target — you want static, or you want dynamic DNS to paper over the changes. Dynamic DNS works, but it adds a dependency: if the update fails, your hostname points at nothing.
Local versus public addresses
This distinction trips up more people than any other part of IP addressing.A local address, also called a private address, is used inside your own network. The range `192.168.0.0` to `192.168.255.255` is reserved for this, along with `10.0.0.0/8` and `172.16.0.0/12`. These addresses are not reachable from the internet. They exist so devices inside the same network can tell each other apart.
A public address is what the internet sees. Your provider assigns it, and it identifies your whole network from the outside. Every device in your house has its own local address, but they all share one public address through the router. The router translates between the two, a process called NAT.
This is why "what is my IP" gives a different answer depending on where you ask. Ask your own machine and you get the local address. Ask a server on the internet and you get the public one.
Reading your own addresses
The `ip` command is the modern replacement for `ifconfig`, which is deprecated on most distributions. It comes from the `iproute2` package.To see every interface and its addresses:
```bash ip addr show ```
The output lists each interface with its IPv4 and IPv6 addresses. Look for the `inet` line for IPv4 and the `inet6` line for IPv6. The `lo` interface is the loopback, always `127.0.0.1` on IPv4 and `::1` on IPv6.
For a shorter view that only shows addresses:
```bash ip -brief addr show ```
To see which route your traffic takes and which source address it uses:
```bash ip route get 1.1.1.1 ```
That command tells you the outgoing interface and the source address the kernel would pick. When you have multiple interfaces and traffic is going out the wrong one, this is the first thing to check.
Finding your public address
Your machine does not know its own public address. The router does, through NAT, and the only way to learn it is to ask something on the outside.```bash curl -4 https://ifconfig.me ```
The `-4` flag forces IPv4. For IPv6:
```bash curl -6 https://ifconfig.me ```
If the second command fails, your connection or your provider does not support IPv6. That is common and not a problem for most use cases.
You can also query a DNS-based service, which avoids HTTP entirely:
```bash dig +short myip.opendns.com @resolver1.opendns.com ```
Both methods work. The HTTP one is easier to remember; the DNS one works when HTTP is blocked but DNS is not.
How addresses are routed
An IP address is not just a label. It is also a routing instruction, and the routing happens in layers.Inside your network, the router decides which device gets which packet based on the local address. Outside, providers use BGP, the Border Gateway Protocol, to decide which path traffic takes across the internet.
BGP works with IP prefixes — groups of addresses — rather than individual addresses. Every network on the internet has an autonomous system number, and it advertises which prefixes it can reach. BGP picks the best path dynamically, and it does so continuously. When a route goes down, BGP finds another one. When a route is misconfigured, BGP propagates the mistake worldwide in minutes.
That last part is worth remembering the next time a major outage makes the news. The protocol is doing exactly what it was designed to do.
Verification
To confirm everything is working as expected, run these three checks.First, confirm your local address:
```bash ip -brief addr show ```
You should see at least one `UP` interface with an `inet` address. The loopback will show `127.0.0.1`.
Second, confirm your public address:
```bash curl -4 https://ifconfig.me ```
You should get a single IPv4 address back. If you get a timeout or an error, your connection is down or outbound HTTP is blocked.
Third, confirm routing:
```bash ip route get 1.1.1.1 ```
The output should name an interface and a source address. If the source address does not match the interface you expect, you have a routing problem.
Common problems
`ip: command not found`The `iproute2` package is missing. Install it with `sudo apt install iproute2` on Debian and Ubuntu, or `sudo dnf install iproute` on RHEL and Fedora. On minimal container images, this is common — Alpine uses `busybox ip` instead, which has a different syntax.
Two devices with the same IP address
This happens when a static address is assigned inside a DHCP range, or when two devices are configured manually with the same number. Symptoms include intermittent connectivity and ARP conflicts in the logs. The fix is to move static assignments outside the DHCP pool, or to reserve the address in the DHCP server so it is never handed out twice.
Public address changes and breaks things
If your provider gives you a dynamic public address and you run a service that depends on it, the address will change eventually. Options are a static address from your provider, usually for a monthly fee, or dynamic DNS, which updates a hostname when the address changes. Dynamic DNS is cheaper and less reliable. Static is the other way around.
The address you see in `ip a` is not the address the internet sees. That gap, and the machinery that bridges it, is most of what makes a network work.