Subnets and the Network Mask

Netmasks, which travel hand-in-hand with IP addresses when configuring TCP/IP on a machine, are one of the most misunderstood parts of the whole structure, and yet potentially one of the most elegant when understood properly.

The purpose of the network mask (or netmask) is simply to tell a router or host whether a packet is supposed to go to the network it's on or go upstream to the next router. When a router receives a packet and has to decide what to do with it, it checks the packet's destination IP address against its own netmask.

The netmask, a 32-bit string like an IP address, is usually of the form 255.255.255.0. Let's say that we have a router managing the 64.41.131 network, with a netmask of 255.255.255.0 ...

Get Sams Teach Yourself FreeBSD® in 24 Hours now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.