Frontend Labs
⋯

Part 3 — IP addresses and getting around the world

This part contains Chapter 10, the one topic most beginners bounce off. It is not hard. It has just always been taught badly. Go slowly and do the practice.

Chapter 9 — What an IP address actually is

In one sentence

An IP address is a number identifying a machine's location on the network, and it's split into two parts: which network it's on, and which host it is on that network.

The problem

MAC addresses can't scale (Chapter 6): they're flat, so a global router would need a table listing every device on Earth. We need addresses with structure — so a router can say "everything starting with 93.184 goes left" in a single rule.

The idea, in plain language

Use a postcode, not a name.

   MAC address  is like  "Sarah Chen"
        -> to deliver, you'd need a list of everyone on Earth

   IP address   is like  "SW1A 1AA" / "10001"
        -> the postcode itself tells you the routing
        -> the sorting office only needs to know "SW.. goes to London"

An IP address encodes where you are, not who you are. Move your laptop to a café and its MAC stays the same while its IP changes — because its location changed.

How it actually works: the address

An IPv4 address is 32 bits, written as four numbers 0–255 separated by dots:

   192  .  168  .   1   .  50
   \_/     \_/     \_/     \_/
    |       |       |       |
   8 bits  8 bits  8 bits  8 bits     =  32 bits total

   In binary:  11000000 . 10101000 . 00000001 . 00110010

Each of those four numbers is called an octet (8 bits). This is why they max out at 255 (Chapter 0.5).

32 bits gives about 4.3 billion addresses. There are far more than 4.3 billion connected devices, which is the whole reason NAT (Chapter 12) and IPv6 (Chapter 16) exist.

The two halves

Here's the crucial idea, and everything in Chapter 10 follows from it:

   192.168.1.50
   \_________/ \/
        |       |
   NETWORK part  HOST part
   "which street"  "which house"
  • Every device on the same network shares the same network part.
  • Each device has a different host part.
  • A router only needs to know about networks, not individual hosts. That's the scaling win.

But where exactly is the dividing line? That's what the subnet mask tells you — and it's Chapter 10.

Two addresses you never assign to a device

In every network, two addresses are reserved:

   Network 192.168.1.x  (with a /24 mask, explained next chapter)

   192.168.1.0     <- the NETWORK ADDRESS. Names the network itself.
                      All host bits = 0. Never assign it to a device.

   192.168.1.1
   192.168.1.2      <- usable addresses for actual devices
   ...
   192.168.1.254

   192.168.1.255   <- the BROADCAST ADDRESS. "everyone on this network".
                      All host bits = 1. Never assign it to a device.

So a "256-address" network gives you 254 usable addresses. That "minus 2" is the source of endless confusion; now you know exactly why.

Special addresses to recognise

Address / range Meaning
127.0.0.1 Loopback — "this machine". Never leaves your computer. localhost.
0.0.0.0 "Any address" / "unspecified". A server binding to 0.0.0.0 means "listen on all my addresses".
255.255.255.255 Broadcast to this local network only
169.254.x.x Self-assigned — "I asked for an address and nobody answered". A DHCP failure signal (Chapter 17).
10.x.x.x, 172.16-31.x.x, 192.168.x.x Private — usable inside your network, never routed on the internet (Chapter 12)
224.x.x.x – 239.x.x.x Multicast — "everyone subscribed to this group"

Seeing 169.254.something on a device is an instant diagnosis: it never got a DHCP address. That single fact will save you time for the rest of your career.

Practice (15 min)

A. Find and understand your own address:

# Linux
ip -4 addr show
# macOS
ipconfig getifaddr en0 ; ifconfig en0 | grep 'inet '

Write down your address and note which of the private ranges it falls in.

B. See the loopback do nothing:

ping -c 2 127.0.0.1
sudo tcpdump -i any -c 5 -n 'host 127.0.0.1'   # in another terminal, then re-ping

Traffic to 127.0.0.1 appears on the lo interface and never touches your network card.

C. Convert to binary yourself (do at least two by hand before checking):

python3 -c "print('.'.join(format(int(o),'08b') for o in '192.168.1.50'.split('.')))"

Use the place-value table from Chapter 0.5: 192 = 128 + 64 so 11000000.

Common confusions

  • "Is my IP address permanent?" Usually not. Home devices get a new one periodically from DHCP (Chapter 17). Your public IP may also change.
  • "Why does my machine have several IP addresses?" One per interface (Ethernet, Wi-Fi, VPN, Docker) plus loopback. Normal and expected.
  • "What's the difference between my IP and my public IP?" Your device has a private IP (192.168.x.x); your router has a public one shared by everyone in your house. Chapter 12. Try: curl ifconfig.me.
  • "IP address vs domain name?" The name (example.com) is a label for humans; DNS translates it to an address (Chapter 18).

Check yourself

  1. How many bits is an IPv4 address, and why do the octets stop at 255?
  2. What are the two parts of an IP address?
  3. Why can't you assign the network address or the broadcast address to a device?
  4. What does it mean if a device has the address 169.254.10.7?

Further reading

  • Video (~10 min): "IP Addresses Explained" — PowerCert Animated Videos, or Practical Networking's "IPv4 Addressing".
  • Article: "What is an IP address?" — Cloudflare Learning Center.
  • Tool: curl ifconfig.me or visit whatismyipaddress.com to see your public address.

Generated from real-life-guide-v1.md · 8 Oct 2026 16:36