Networking

IPv4 Subnet Mask Calculator

Calculate subnet masks, wildcard masks, network address, broadcast address, and host ranges from IPv4 CIDR notation.

Subnet Mask

255.255.255.0

Wildcard Mask

0.0.0.255

Network

192.168.1.0

Broadcast

192.168.1.255

First Host

192.168.1.1

Last Host

192.168.1.254

Total Addresses

256

Usable Hosts

254

Understanding IPv4 Subnets and CIDR Masks

IPv4 subnetting divides a 32-bit address space into network and host portions. CIDR notation writes the prefix length after a slash, such as 192.168.1.42/24. The /24 means that the first twenty-four bits identify the network, while the remaining eight bits identify hosts inside that network. Subnetting is essential for routing, firewall rules, VLAN design, lab networks, embedded Ethernet products, and cloud infrastructure.

Although subnetting is often taught as a networking topic, hardware and embedded engineers run into it constantly. Development boards expose web configuration pages, industrial controllers sit on plant networks, cameras stream data to recorders, and test fixtures need deterministic addresses. When a device has the wrong mask, it may appear online to itself but unreachable from the engineering workstation. A quick subnet check can separate network configuration problems from firmware or hardware failures.

Subnet Mask Calculation

A subnet mask has ones in the network portion and zeros in the host portion. A /24 mask is therefore 255.255.255.0. A /26 mask is 255.255.255.192 because the first two bits of the final octet are part of the network. The wildcard mask is the inverse of the subnet mask, so 255.255.255.0 becomes 0.0.0.255. Wildcard masks appear in access-control lists and routing configurations where matching host bits are described by zeros and ones in the opposite way.

CIDR replaced older classful assumptions where addresses were grouped as Class A, B, or C by their leading bits. Modern networks use whatever prefix length fits the design. A /30 might be used for a small point-to-point link, a /24 for a lab VLAN, and a /20 for a larger routed segment. The prefix length determines both the mask and the block size, so understanding CIDR is more useful than memorizing only a few common masks.

Network and Broadcast

The network address is found by applying a bitwise AND between the IP address and subnet mask. The broadcast address is found by setting all host bits to one. In a traditional subnet larger than /31, the first usable host is one above the network address and the last usable host is one below the broadcast address. The number of usable hosts is normally 2^(host bits) - 2. Point-to-point /31 networks and single-address /32 routes have special behavior, so modern tools report usable counts without blindly subtracting two.

The broadcast address is important because traffic sent there is intended for every host in the subnet. Many discovery protocols, legacy services, and diagnostic tools rely on broadcast behavior. Routers normally do not forward local broadcasts, so devices that are one subnet apart may not discover each other automatically even if a routed path exists. This distinction is a frequent source of confusion in lab networks and production test systems.

Manual Example

For 192.168.1.42/24, the mask is 255.255.255.0. The network address is 192.168.1.0, the broadcast address is 192.168.1.255, and the ordinary usable range is 192.168.1.1 through 192.168.1.254. For 192.168.1.42/26, the host block size is 64 addresses. The address 42 belongs to the 0-63 block, so the network is 192.168.1.0 and the broadcast is 192.168.1.63. These calculations become easier when the binary boundary is visible.

Engineering Use

Subnet calculators are useful for embedded Linux devices, lab benches, routers, switches, test fixtures, industrial controllers, and cloud-connected hardware. A wrong subnet can make a device look defective when it is simply unreachable. Knowing the network, broadcast, and host range helps engineers configure static IPs, DHCP scopes, firewall rules, and packet captures without guesswork.

Troubleshooting should include the gateway and host route table, not only the address and mask. Two devices can be configured with valid addresses and still fail to communicate if they are in different subnets without a route between them. On embedded Linux, commands such as ip addr and ip route reveal whether the interface, prefix, and default gateway agree with the intended network plan.