how/network
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".
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
links10.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 NAT127.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)/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.