IP Addresses Explained: How to Read IPv4, IPv6, Subnets and NAT

Diagram of a phone and laptop sending traffic through a home router using NAT to reach a web server by IP address

An IP address is a numeric label that identifies a device's network interface so traffic can be routed to it. With IP addresses explained step by step, any address you see in a settings screen or log file becomes readable. You can tell its version, its prefix and its scope, and those three facts tell you most of what you need to know.

This guide builds the idea up one piece at a time. It starts with what an address is and why the internet needs addresses at all. Then it covers IPv4 and IPv6, subnets, private ranges and NAT, loopback and DHCP, and a single page load that uses all of them. It finishes with three mistakes that catch out even experienced people.

In short
  • An IP address labels a network interface, not a whole device, and routers use it to forward packets.
  • IPv4 uses 32 bits (about 4.3 billion addresses); IPv6 uses 128 bits and has room for every device.
  • A prefix like /24 splits an address into a network part and a host part.
  • Private ranges (10.x, 172.16–31.x, 192.168.x) stay local, and NAT lets them share one public address.
  • Before acting on any address, check its version, prefix and scope.
  1. 0:00Intro
  2. 0:23Why reading an address matters
  3. 1:21What an IP address really is
  4. 2:20Finding the way across many networks
  5. 3:18IPv4 vs IPv6
  6. 4:19Network part, host part
  7. 5:33Private ranges share one public address
  8. 6:43Loopback and DHCP
  9. 7:46One page load, every address
  10. 8:50Three mistakes that trip people up
  11. 9:51Everything that makes an IP readable
  12. 10:35Know the version, prefix and scope

Why does reading an IP address matter?

When something on a network breaks, the address is usually the first clue. Read it wrong and you chase the wrong problem. Familiar situations include a laptop that says it's connected but has no internet, a device that shows several addresses with no hint of which one matters, and a printer that stops working the moment you join a VPN.

Debugging almost always starts with the address. When a page won't load, check which address you got and where it came from. That tells you whether the problem lies with your device, your router or something further out. Conflicts are the other common case. If two connected networks use the same range, traffic can go the wrong way.

  • Debugging connections: most network fixes start by reading an address.
  • Avoiding conflicts: two networks on the same range send traffic the wrong way.

What is an IP address?

An IP address is a numeric label for a network interface. Its purpose is to let traffic be routed to that interface. Think of the address on an envelope. The postal system doesn't care what's inside. It only reads the address to decide where the letter goes next. Routers treat packets the same way.

Here is a simple path. A phone holds the address 192.168.1.20. It hands a packet to the home router, which sends it across the internet until it reaches a web server at 198.51.100.10. At every hop, only the address is read.

The important detail is that an address belongs to an interface, not to the whole device. A laptop connected over Wi-Fi and Ethernet at the same time has two addresses. So whenever you see an IP, ask which interface it points to.

  • Per interface: Wi-Fi and Ethernet each get their own address.
  • Used for routing: routers read it to forward every packet.

Why do IP addresses exist? Routing across networks

The internet isn't one network. It's thousands of separate networks joined together, and packets need a way to find their destination across all of them. No single machine knows the whole path in advance. Each network moves the packet one step closer, based on the address it carries, and trusts the next network to do the same.

Follow one packet. Your laptop sets the destination address. The home router forwards the packet to your ISP's network, which hands it to the internet backbone. Finally, the server's network delivers it to the right machine. The sender stamps the destination address on the packet, and it stays the same for the whole trip, even if the path changes.

This is called hop-by-hop routing. Each router decides only the next step, much like runners passing a baton in a relay. Shared addressing is what makes that cooperation possible.

IPv4 vs IPv6: what's the difference?

Two versions of IP are in everyday use. They do the same job but are built very differently, and the main difference is size. The number of bits decides how many unique addresses can exist, and that single design choice explains almost everything else about the two versions.

IPv4 uses 32 bits, written as four decimal numbers such as 192.168.1.20. That allows about 4.3 billion addresses, and IPv4 has effectively run out, so it leans heavily on NAT. IPv6 uses 128 bits, written as hexadecimal groups such as 2001:db8::20. That allows roughly 3.4×10³⁸ addresses, enough for every device.

Most networks run both versions side by side, an approach called dual stack. Your device often has an IPv4 address and an IPv6 address, and it uses whichever one the other side supports. Always check which version you're looking at before drawing conclusions.

  • Length: 32 bits vs 128 bits
  • Format: 192.168.1.20 vs 2001:db8::20
  • Total: about 4.3 billion vs about 3.4×10³⁸
  • Today: IPv4 has run out and relies on NAT; IPv6 has room to spare

Subnet masks and CIDR: network part vs host part

Every IP address splits into two parts. The network part says which network, and the host part says which device on that network. It works like a street name and a house number. The prefix tells you how many leading bits form the street, and the remaining bits are the house number.

Take 192.168.1.20/24 as an example. The /24 means the first 24 bits are the network part. Written as a subnet mask, that's 255.255.255.0. The network is 192.168.1.0 and the host part is .20. The network holds 254 usable hosts, because the first and last addresses in the range are reserved.

Mask and CIDR notation carry the same information. Older tools tend to show 255.255.255.0, and newer ones write /24. The split also has a practical effect. Two addresses with the same network part talk to each other directly. If the network parts differ, traffic has to go through a router.

  • 255.255.255.0 and /24 mean the same thing.
  • Same network part: direct delivery, no router needed.
  • Different network part: traffic goes through the router.

Private IP addresses and NAT: how one public IP is shared

Billions of devices fit into IPv4's 4.3 billion addresses because most of them use private addresses at home or at work. Millions of homes reuse the same private addresses at the same time. That only works because these addresses never travel onto the public internet unchanged.

The technique that makes this possible is NAT, short for Network Address Translation. The router rewrites the address on each packet as it leaves your network and changes it back on the way in. A phone at 192.168.1.20 and a laptop at 192.168.1.21 both send through the home router, which swaps their private addresses for its single public address, 203.0.113.5, before the traffic reaches the web server.

The private ranges are fixed, so they are easy to spot. If an address falls in one of them, it's local to its own network.

  • 10.x.x.x
  • 172.16.x.x through 172.31.x.x
  • 192.168.x.x

What are 127.0.0.1 (loopback) and DHCP?

Two special cases come up constantly. One is an address that always means this machine. The other is a system that hands out addresses so you never have to type them in. Both are built into every modern operating system. Without them, testing software locally and joining a new Wi-Fi network would each need manual setup.

Loopback, 127.0.0.1, is the address of your own computer. Traffic sent there never leaves the machine, which is why developers test their work on localhost. In IPv6, loopback is written as ::1.

DHCP assigns addresses automatically in four steps. Your laptop broadcasts a Discover message asking whether any server is available. The router replies with an Offer, such as 192.168.1.20. The laptop sends a Request to accept it, and the router confirms with an ACK. The address is lent for a set time, called a lease, and can be renewed.

  • Discover: is any server there?
  • Offer: 192.168.1.20
  • Request: I'll take it
  • ACK: lease granted

What happens to your IP address when you open a website?

A single page load at home uses every idea covered so far. The useful thing to watch is the addresses, not the page. The source address changes on the way out, while the destination address never does.

You open example.com. Your laptop already got 192.168.1.20 from DHCP, and that private address tells it to send the packet to the home router. The router performs NAT, rewrites the source to its public address 203.0.113.5, and records the swap in its NAT table. The packet is then routed hop by hop to the web server at 198.51.100.10.

The server sends its reply to 203.0.113.5, because that's the only address it ever saw. The router looks up the matching entry in its NAT table and forwards the reply to 192.168.1.20. That table is how one public address serves a whole household.

Common IP address mistakes and how to avoid them

Most errors come from misjudging an address's scope or overestimating what it reveals. None of them takes deep theory to avoid. A quick check of the version, the prefix or the scope is usually enough.

The classic mistake is sharing a private address. Your friend can't reach your server because you gave them 192.168.1.20, which only works inside your home. Share your public IP instead and forward a port on your router. The second trap is overlapping subnets. If your home network and your office VPN use the same range, your device can't tell which network an address belongs to. Choose distinct ranges before linking networks.

The third mistake is treating an IP address like GPS. Lookup sites only guess a rough region or the internet provider, and they're often far off. Treat IP location as a hint, never as proof.

  • Don't share a 192.168.x address with someone outside your network.
  • Don't link two networks that use the same range.
  • Don't trust IP geolocation as a precise location.

Key takeaways

  • An IP address labels a network interface so packets can be routed to it.
  • IPv4 is 32 bits and IPv6 is 128 bits, and most devices run both.
  • The prefix (/24 or 255.255.255.0) splits the network part from the host part.
  • Private ranges stay local and share one public IP through NAT.
  • 127.0.0.1 is loopback, and DHCP assigns addresses automatically.
  • An IP address hints at location but never pinpoints it.

Frequently asked questions

Why does my laptop have more than one IP address?

Addresses belong to network interfaces, not to whole devices. A laptop using Wi-Fi and Ethernet at once has an address on each, and with dual stack it may also have both IPv4 and IPv6 addresses.

How can I tell if an IP address is private or public?

Check whether it falls in a private range: 10.x, 172.16 through 172.31, or 192.168. If it does, it's local to its own network. Anything outside those ranges that's reachable on the internet is public.

What does /24 mean in an IP address?

It's a CIDR prefix meaning the first 24 bits identify the network. It's the same as the subnet mask 255.255.255.0 and gives 254 usable host addresses.

Is IPv6 replacing IPv4?

Both are in everyday use. Most networks run them side by side with dual stack, and devices use whichever version the other side supports.

Can someone find my exact location from my IP address?

No. IP lookup sites only guess a rough region or your internet provider, and they're often wrong. Treat IP location as a hint, not as proof of where someone is.

What is 127.0.0.1 used for?

It's the loopback address, which always means your own machine. Traffic sent there never leaves the computer, which makes it useful for testing software on localhost. The IPv6 equivalent is ::1.

Watch the full video on YouTube →

Souy Soeng

Souy Soeng

Hi there 👋, I’m Soeng Souy (StarCode Kh)
-------------------------------------------
🌱 I’m currently creating a sample Laravel and React Vue Livewire
👯 I’m looking to collaborate on open-source PHP & JavaScript projects
💬 Ask me about Laravel, MySQL, or Flutter
⚡ Fun fact: I love turning ☕️ into code!

Post a Comment

CAN FEEDBACK
Ad