Which addresses does the PC treat as local?
PC-A is 192.168.10.10/24. It wants to reach PC-B at 192.168.10.20 and a server at 192.168.20.5. Before it sends anything, it needs to distinguish a local neighbour from a destination reached through router R1.
A subnet is an IP address range with a shared network prefix. On a simple Ethernet or Wi-Fi LAN, hosts in that subnet normally reach one another directly. The address range and the physical connection are separate: matching addresses do not join two disconnected cables.
A subnet mask is a number that is configured together with every IP address. It tells the device which part of its address identifies the network and which part identifies the host (the device itself). Without the mask, 192.168.10.25 is just four numbers. With the mask 255.255.255.0, it means “device 25 on network 192.168.10”.
Changing a mask changes what a host believes is local; it does not move devices onto the same physical network. That distinction explains why a broader mask can break a connection rather than make it reach more places.
Why the mask exists
Every time a device sends something, it has to answer one question first:
“Is the destination on my own subnet, or somewhere else?”
On my subnet → send it straight there. Somewhere else → send it to the router (the default gateway).
The device can only answer this if it knows where its own network part ends. That is the mask's job. The mask also helps routers: instead of storing a route for every single device, a router stores whole networks, such as “192.168.10.0/24 is through this interface”. One /24 route covers the whole address block, with 254 conventional host addresses.
Four terms that come with every mask
Network portion
The left part of the address. Every device on the same subnet has exactly the same network portion. It identifies the network, like a street name.
Host portion
The right part of the address. It is different for every device on the subnet. It identifies one device, like a house number on that street.
Subnet mask
A second 32-bit number, written like an address. A 1 bit marks a network bit; a 0 bit marks a host bit. In /24 and /16 examples, the boundary falls between whole octets.
Prefix length (/24)
A short way to write the mask: the number of network bits. /24 means the first 24 bits (3 octets) are the network portion, the same as 255.255.255.0.
Reading a mask: network portion and host portion
A mask looks like an IP address, but it means something different. Line it up under the address and compare them octet by octet:
- 255 in the mask → that octet of the address is network.
- 0 in the mask → that octet of the address is host.
Behind the scenes, a mask is 32 bits: a row of 1s (network) followed by a row of 0s (host). 255 is simply eight 1s in binary (11111111), and 0 is eight 0s. The IP address lesson shows these bits.
Learn more: What Is an IP Address?
Slash notation: what /24 means
Writing 255.255.255.0 every time is slow, so you can count the 1 bits instead and write the number after a slash. This is called the prefix length or CIDR notation (Classless Inter-Domain Routing).
| Prefix | Subnet mask | Network part | Host part | Example | Addresses |
|---|---|---|---|---|---|
| /8 | 255.0.0.0 | first octet | last 3 octets | 10.1.2.3/8 | 16,777,216 |
| /16 | 255.255.0.0 | first 2 octets | last 2 octets | 172.16.45.200/16 | 65,536 |
| /24 | 255.255.255.0 | first 3 octets | last octet | 192.168.10.25/24 | 256 |
So 192.168.10.25/24 and “192.168.10.25, mask 255.255.255.0” mean exactly the same thing. Windows shows the dotted mask; Linux and many network devices show the slash.
The network address and the broadcast address
Set all the host bits to 0 and you get the network address, which identifies the subnet itself. Set all the host bits to 1 (255 in each host octet) and you get the broadcast address, which reaches every device on the subnet. For the /24 and /16 LANs here, neither address is assigned to an ordinary host. Special /31 point-to-point links and /32 host routes follow different rules.
| Address | Network address | Usable hosts | Broadcast |
|---|---|---|---|
| 192.168.10.25/24 | 192.168.10.0 | .1 to .254 (254 hosts) | 192.168.10.255 |
| 172.16.45.200/16 | 172.16.0.0 | 172.16.0.1 to 172.16.255.254 | 172.16.255.255 |
How a device uses the mask, step by step
For a basic host with its connected subnet and a default route, we can explain the decision using the mask. More generally, the host selects a matching route; an explicit, more specific route can change the next hop:
Read in arrow direction. Labels describe each stage or hop; connectors show the sequence, not a complete physical cabling plan or time to scale.
Example 1: two addresses with /24
Example 2: the same addresses with /16
Now give the devices a /16 mask. Only the first two octets are compared:
Same two addresses, different answer. Whether two devices are “on the same subnet” is decided by the mask, not by the addresses alone. That is why you must always read an address together with its mask.
Practice table
| My address | Destination | Compare | Result |
|---|---|---|---|
| 192.168.1.50/24 | 192.168.1.200 | 192.168.1 = 192.168.1 | Same subnet |
| 192.168.1.50/24 | 192.168.2.50 | 192.168.1 ≠ 192.168.2 | Different subnet |
| 10.20.5.9/16 | 10.20.200.1 | 10.20 = 10.20 | Same subnet |
| 10.20.5.9/16 | 10.21.5.9 | 10.20 ≠ 10.21 | Different subnet |
| 172.16.4.1/24 | 172.16.40.1 | 172.16.4 ≠ 172.16.40 | Different subnet |
What the mask does to real traffic
The diagram shows an office with two subnets connected by a router. PC-A uses its mask to decide where each packet goes:
Device key: PC-A (laptop) · PC-B (computer)
Lines show the example’s network connections. The coloured path and envelope follow the current step; its text identifies the sender, receiver and traffic type.
Reading the addresses
IP labels identify interfaces or destinations. Subnet labels identify networks; /n is the prefix length. A router ID (RID) identifies a routing process and need not be a reachable interface.
An IP address alone is not a URL. A web URL includes a scheme such as https://; an address on a router or printer does not imply a website.
- PC-A: IP 192.168.10.10/24
- PC-B: IP 192.168.10.20/24
- Router: .10.1 | .20.1
- Server: IP 192.168.20.5/24
- 1. Same network part: direct. 192.168.10 matches PC-A's own network part, 192.168.10, so PC-A sends the frame straight to PC-B through the switch. The router is not involved.
- 2. Different network part: to the gateway. 192.168.20 does not match 192.168.10, so PC-A sends the packet to its default gateway, 192.168.10.1.
- 3. The router delivers it. The router has an interface in 192.168.20.0/24 and forwards the packet to the server.
One important detail: the ordinary IPv4 header has no subnet-mask field. The IP header carries the source and destination addresses, but not the mask. Each device uses its own configured mask to make its own decision. That is why a single device with a wrong mask can break its own traffic while every other device works normally.
Masks you will meet at home and at work
| Network | Typical setting | Why |
|---|---|---|
| Home Wi-Fi | 192.168.1.0/24 | 254 usable addresses are plenty for a home |
| Office floor | 10.20.30.0/24 | Separate VLANs with routed subnets can limit broadcasts; the mask alone does not |
| Large campus or lab | 172.16.0.0/16 | Up to 65,534 devices in one subnet (rarely a good idea in practice) |
Real networks also use masks that split an octet, such as /26 or /30, to make smaller subnets. Working those out is called subnetting. It needs binary and is taught in the CCNA course. You can also let the Subnet Calculator do the maths.
Learn more: Subnetting
What happens with a wrong mask
Keep the cables and addresses in place and change only PC-A's mask. This is a useful experiment because it separates the physical network from the PC's idea of that network. In this example there are no extra host routes or proxy ARP replies to hide the mistake.
On small screens, swipe sideways or focus the diagram and use the arrow keys.
With the correct /24, PC-A compares 192.168.10.10 with the server at 192.168.20.5 and gets different network prefixes. It therefore selects R1 as the next hop and, if necessary, uses ARP to find the MAC address of 192.168.10.1. ARP means Address Resolution Protocol: it asks which Ethernet address belongs to a nearby IPv4 address.
With the mistaken /16, both addresses appear to belong to 192.168.0.0/16. PC-A now sends an ARP request for the server itself. The request stays on the left LAN; it does not reach the server across R1. The PC has chosen the wrong next receiver before the router gets a chance to forward the data. Correct the mask, then check the route and neighbour entry again rather than assuming a working cable proves the IP settings are right.
Devices that get their address from DHCP receive the mask with it, so wrong masks turn up mostly on addresses typed in by hand: printers, servers and lab machines. Assume the correct setting for PC-A is 192.168.10.10/24.
| Mistake | What PC-A believes | What breaks |
|---|---|---|
| Mask too short: 255.255.0.0 (/16) | Every address starting with 192.168 is local | It tries to reach 192.168.20.5 directly, sends an ARP request for it and gets no answer. Other 192.168.x.x subnets fail, but the internet still works. |
| Mask too long: 255.255.255.255 (/32) | Only itself is local | There is no ordinary connected subnet containing the gateway. Delivery may fail unless the platform has an explicit on-link route. /32 is useful in other designs, but is not a replacement for this LAN's /24. |
| Mask typo: 255.255.255.0 typed as 255.255.0.255 | Nothing: this is not a valid mask | The operating system rejects it. A valid mask is always all 1s first, then all 0s. |
Checking the mask on your computer
C:\> ipconfig Ethernet adapter Ethernet: IPv4 Address. . . . . . . . . . . : 192.168.10.10 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.10.1
255.255.255.0 is the mask in dotted decimal, the same as /24. Together with the IPv4 Address, it tells you the PC is on 192.168.10.0/24.$ ip -4 addr show eth0 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000 inet 192.168.10.10/24 brd 192.168.10.255 scope global dynamic eth0 valid_lft 85100sec preferred_lft 85100sec
inet line shows the address with its prefix, 192.168.10.10/24, and the broadcast address (brd 192.168.10.255) worked out from that prefix.$ ip route default via 192.168.10.1 dev eth0 proto dhcp metric 100 192.168.10.0/24 dev eth0 proto kernel scope link src 192.168.10.10 metric 100
192.168.10.0/24 dev eth0 means “this subnet is directly connected to eth0” (local). Every other destination matches the default via 192.168.10.1 line and goes to the gateway.Troubleshooting tip: compare the mask on the broken PC with the mask on a working PC in the same room. Confirm both PCs belong to the same intended subnet or VLAN first; two PCs in one room can be on different networks.
Five ways to misread a mask
- Judging “same subnet” by the first three octets every time. That only works for /24. With /16, you compare only the first two octets.
- Forgetting that each device uses its own mask. The mask is not carried in the packet, so a wrong mask on one device only affects that device's decisions.
- Giving a device the network or broadcast address (for example,
192.168.10.0or192.168.10.255on a /24). These addresses identify the subnet and reach all devices, so they cannot be used by one host. - Guessing the mask from the first octet (“10 means /8”). A 10.x.x.x network is often split into /24 subnets, so always read the configured mask.
- Thinking a bigger prefix number means a bigger network. It's the opposite: more network bits leave fewer host bits, so a /24 is smaller than a /16.
- The mask splits an address into a network portion and a host portion.
- 255 in the mask = network octet; 0 = host octet. /24 = 255.255.255.0, /16 = 255.255.0.0.
- Two addresses are on the same subnet if their network portions match, using the sender's mask.
- Same subnet → deliver directly; different subnet → send to the default gateway.
- The mask isn't in the packet. A wrong mask usually breaks only the device that has it.
Short lab: prove what the mask changes
- Read your current settings with Windows
ipconfigor Linuxip -4 addr. Record the active interface's address and mask. Do not change a live office network to match this example. - On paper, compare PC-A
192.168.10.10/24with PC-B192.168.10.20. Both produce network192.168.10.0. Compare PC-A with192.168.20.5: that destination produces192.168.20.0. - Change only the paper example to /16. Both destinations now produce
192.168.0.0. Explain why PC-A would ask directly for the server, even though the server is really beyond R1. - On Linux,
ip route get 192.168.20.5shows the route your own system would select. Aviavalue names a next-hop router;devnames the outgoing interface. Your result may differ because your real network is different.
The historical Class A, B and C approach tied masks to address ranges. Classless addressing uses an explicit prefix instead. A shorter prefix offers more host addresses, but a large shared LAN also has more devices to manage and more broadcast traffic to consider.
Test yourself: same subnet or not?
PC-A is 192.168.10.10/24. Is 192.168.10.200 on the same subnet?
A server is 10.5.1.20/16. Is a PC at 10.5.99.7 on the same subnet?
A router shows an interface as 192.168.10.1/24. Which dotted-decimal mask should you type on a PC on that subnet?
PC-A should be 192.168.10.10/24 but is set to /16. It can't reach 192.168.20.5, a server on another subnet. Why?
Next, learn about the router address that carries traffic to other subnets.
Learn more: The Default Gateway
Technical references
Prefix notation follows RFC 4632. Host local/remote decisions are described in RFC 1122, section 3.3.1.1. Windows display commands follow Microsoft ipconfig documentation. Outputs are illustrative.