linuxlab.io
Tutorials▾
  • Linux & networking
    File system, processes, TCP/IP, BGP and OSPF
    →
  • Terraform & IaC
    HCL, state, plan/apply on a LocalStack sandbox
    →
  • Git & GitHub
    Object model, plumbing, branching, GitHub Actions
    →
All tutorials →
PricingAboutSign inCreate account
/
Intro
Lessons
Footer
linuxlab-TutorialsPricingAboutPrivacy & cookies
Copyright © 2026 LinuxLab. All rights reserved.
linuxlab.io
Tutorials▾
  • Linux & networking
    File system, processes, TCP/IP, BGP and OSPF
    →
  • Terraform & IaC
    HCL, state, plan/apply on a LocalStack sandbox
    →
  • Git & GitHub
    Object model, plumbing, branching, GitHub Actions
    →
All tutorials →
PricingAboutSign inCreate account
/
  • Introduction
  • Lessons
  • How it works
  • Simulator
  • Knowledge base
  • Interview prep
home/linux/how/subnetting

how/network

Subnets and CIDR

Where does the /24 in an IP address come from? Why are two hosts with similar IPs on the same network, while different ones are on different networks? It all comes down to bits.

You see notations like 192.168.1.50/24 or 10.0.0.0/8 all the time. What does this /N after the slash mean?

The simple answer: an IP address is 32 bits, and /N says to treat the first N of them as the "network number". Everything else follows from this: which addresses are "local", which are "remote", what broadcast is, and why two hosts do or do not need a router between them.

Press ▶ to see these 32 bits with your own eyes and follow how a bitwise comparison decides "my network or someone else's".

step 1/5·00 · An IP is just 32 bits
192.168.1.50192.168.1.5011000000101010000000000100110010ip-адрес - это 32 бита. в десятичной записи - 4 октета по 8 бит каждый

§ steps

  1. 192.168.1.50 in decimal we all read easily. But the computer sees a 32-bit number, four "octets" of 8 bits each.

    192      168       1        50
    11000000.10101000.00000001.00110010

    The dots between octets are a purely human separator, for convenience. Inside it is just 32 consecutive bits.

recap

What to remember:

  • /N = N bits out of 32 for the network number, the rest for the host number. /24 = 256 addresses in the subnet, 254 usable (minus network and broadcast). /30 = only 4 addresses, 2 usable, for point-to-point links
  • Network address (host bits all zero) and broadcast (host bits all one) are reserved, you cannot assign them. Every other address in the range is usable
  • To tell "same subnet or not", compare the first N bits of two addresses. They match: same subnet, send through arp. They differ: different subnets, go through the [[default-gateway|router]]
  • Private ranges (RFC 1918): 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16. They are not routed on the internet, which is why home networks sit behind NAT
  • Special ones: 127.0.0.0/8 loopback (talking to itself), 169.254.0.0/16 link-local (when DHCP did not work), 224.0.0.0/4 multicast, 0.0.0.0/0, which "matches everything" (default route)
  • IPv6 uses the same logic, only the address is 128 bits and ordinary subnets are /64 (huge)

If you want to play with the bits by hand, there is ipv4-addressing plus the ipcalc 192.168.1.50/24 command.

§ dig into the knowledge base

  • ipv4-addressingIPv4 addressing, the extended article
  • broadcast-domainbroadcast domain, where "my network" applies
  • arpARP, what happens when it is "the same subnet"
  • default-gatewaydefault-gateway, what happens when they are "different"
Footer
linuxlab-
Copyright © 2026 LinuxLab. All rights reserved.
Tutorials
Pricing
About
Privacy & cookies