IP Addresses & Routing

Network, Broadcast and Host Addresses

Learn which addresses in a subnet you can assign, why two are reserved and how /31, /32, cloud networks and IPv6 differ.

Key takeaways

  • The network address has all host bits set to zero and identifies the subnet itself.
  • The broadcast address has all host bits set to one and reaches every device on that subnet.
  • Usable hosts normally equal 2 to the number of host bits, minus two, and the gateway uses one of them.
  • A /31 point-to-point link, a /32 single address, cloud subnets and IPv6 each follow somewhat different rules.

In an ordinary IPv4 subnet, the lowest address names the network, the highest is the broadcast address and everything between them can be assigned to hosts. In 192.168.1.0/24, that means .0 is the network, .255 is the broadcast and .1 through .254 are for devices, the router included.

The rule is easy to state and easy to misapply, because it depends on the mask. An address that is a perfectly good host in one subnet can be a reserved edge in another.

Three kinds of address in one block

Every IPv4 address splits into a network part and a host part, as set by the mask. Look only at the host part:

  • All zeros: the network address.
  • All ones: the directed broadcast address.
  • Anything else: a host address.
The edges and middle of 192.168.1.64/27
192.168.1.64 1 .65 to .94 2 192.168.1.95 3 Network address Host bits all zero. Names the subnet in routes. 1 Host addresses 30 assignable addresses, one usually for the gateway. 2 Broadcast address Host bits all one. Reaches everything in this subnet. 3 192.168.1.64 1 .65 to .94 2 192.168.1.95 3 Network address Host bits all zero. Names the subnet in routes. 1 Host addresses 30 assignable addresses, one usually for the gateway. 2 Broadcast address Host bits all one. Reaches everything in this subnet. 3

A /27 has 5 host bits, so 32 addresses and 30 usable hosts. If the arithmetic is unfamiliar, subnet masks and how to calculate them walks through the block size method.

The network address

The network address is how routing tables and diagrams refer to a subnet: "route 192.168.1.64/27 via this next hop". No device is normally assigned it.

The reservation is partly historical. Very early implementations used the all-zeros host value as a broadcast address, and keeping it unassigned avoids ambiguity. Some modern systems will accept it as a host address in certain configurations, but other equipment may not, so do not rely on it.

The broadcast address

A broadcast is one transmission addressed to everyone on a segment. The directed broadcast is the subnet's top address. On Ethernet it goes out as a frame to the all-ones hardware address, ff:ff:ff:ff:ff:ff, and every network interface on the segment receives it.

There is a second form, the limited broadcast, 255.255.255.255. It means "everyone on this local link" and is never forwarded by routers. A device that has no address yet uses it to find help: the opening message of DHCP is the classic example, sent from 0.0.0.0 to 255.255.255.255.

Two kinds of IPv4 broadcast
Limited broadcast Address is 255.255.255.255 Stays on the local link Usable before a device has an address Used when asking for configuration Directed broadcast Top address of a specific subnet Names the subnet it targets Routers should not forward it by default Seen in discovery and wake tools VS Limited broadcast Address is 255.255.255.255 Stays on the local link Usable before a device has an address Used when asking for configuration Directed broadcast Top address of a specific subnet Names the subnet it targets Routers should not forward it by default Seen in discovery and wake tools

Directed broadcasts from other networks were once abused to amplify attacks: one forged packet could provoke replies from many hosts. For that reason, RFC 2644 changed the default so routers do not forward them onto the target subnet. Leave that protection on.

Why broadcast traffic matters

Every device must at least look at each broadcast. A few are harmless and necessary. ARP uses broadcasts to ask which hardware address owns an IP address. On a very large flat network, or one with a switching loop, broadcasts can consume capacity and processor time on every device at once.

Routers do not pass ordinary broadcasts between subnets, so each subnet, or VLAN, forms its own broadcast domain. Splitting a large network limits how far the chatter and any storm can travel. Some services that depend on broadcasts, DHCP included, then need a relay on the router to forward requests to a server elsewhere.

Counting usable addresses

Prefix Total addresses Usable hosts
/22 1,024 1,022
/24 256 254
/26 64 62
/28 16 14
/29 8 6
/30 4 2

Subtract again for infrastructure. A /29 with a router, a firewall pair sharing a virtual address and two switches may have nothing left for the equipment you meant to put there.

Only the true edges are reserved. In 10.0.0.0/23, the range runs from 10.0.0.0 to 10.0.1.255. The addresses 10.0.0.255 and 10.0.1.0 lie in the middle and are ordinary hosts. Some old software treats any address ending in 0 or 255 with suspicion, so a cautious administrator may leave them out of DHCP pools anyway.

Working out the edges

Given any address and prefix, you can find all four landmarks: network, first host, last host and broadcast. Take 10.8.6.77/28.

  1. A /28 has 4 host bits, so blocks of 16.
  2. Multiples of 16 near 77 are 64 and 80.
  3. The network address is 10.8.6.64.
  4. The broadcast is one below the next block: 10.8.6.79.
  5. Hosts run from 10.8.6.65 to 10.8.6.78.

For a larger block, 10.8.6.77/21 has a block size of 8 in the third octet. Six falls in the block starting at 0, so the network is 10.8.0.0, the broadcast is 10.8.7.255 and hosts run from 10.8.0.1 to 10.8.7.254.

The same address belongs to very different neighborhoods depending on the prefix. That is why an address quoted without its mask is only half the information.

The gateway is just a host

No standard requires the router to use a particular address. Convention puts it at the first usable address, and some networks prefer the last. Pick one convention and apply it everywhere. What matters is that the gateway address is inside the subnet and that devices are configured to point at it, as described in default gateway.

The exceptions

/31 links. A /31 has only two addresses. Under the ordinary rule neither would be usable. RFC 3021 defines that on point-to-point links both are host addresses, with no network or directed broadcast address.

/32. A single address with no host bits. It appears on router loopback interfaces, in host routes, in firewall rules naming one machine and on some VPN or provider connections where the gateway is reached by a special route.

Cloud subnets. Cloud platforms commonly reserve more than two addresses in each subnet for their router, name service and future use. A small subnet therefore offers fewer usable addresses than the textbook figure. Check your platform's documentation. Cloud networking basics covers the surrounding concepts.

Virtual addresses. Redundant gateways often use three addresses: one for each router and a shared one that clients use.

Features that rely on broadcast

Several everyday conveniences are built on broadcasts, and they stop working when a router sits between the parties:

  • Address assignment. Without a DHCP relay, clients on a new VLAN get nothing and may fall back to a self-assigned address beginning 169.254.
  • Wake-on-LAN. The wake signal is commonly sent as a broadcast on the sleeping machine's segment.
  • Some device discovery and older file sharing. Setup apps for printers and gadgets may find nothing from another subnet.
  • Some local multiplayer games. They announce sessions to the local segment only.

When a feature worked before a network was split and fails afterward, this is the first thing to suspect. The remedies are a relay or helper function made for that service, configuring the device by address, or putting the two parties on the same segment. Avoid a blanket rule that forwards all broadcasts between segments, which undoes much of the reason for separating them.

IPv6 has no broadcast

IPv6 removed broadcast altogether and uses multicast, which delivers to a group of interested devices. The all-nodes link-local group, ff02::1, comes closest to the old behavior. Neighbor lookups go to much narrower groups, so most devices are not disturbed.

There is also no subtraction of two. The all-ones interface identifier is not a broadcast address. The all-zeros one has a defined meaning as the subnet-router anycast address, so avoid assigning it to a host. In practice a /64 is so large that counting usable addresses has no point.

Seeing it on your own network

On Linux, the broadcast address is often shown next to the interface address:

ip -4 addr show

Look for a line such as inet 192.168.1.20/24 brd 192.168.1.255. On macOS, ifconfig prints a broadcast value. On Windows, ipconfig shows the address and mask, from which you can work out both edges. To list every address in a block, use the subnet host generator.

You may notice that pinging a broadcast address returns few or no replies. Many systems ignore broadcast pings on purpose, so silence says little about whether hosts are present.

Sizing a DHCP pool around the edges

When you define an address pool, start at least one above the network address and stop at least one below the broadcast, then carve out the gateway and anything fixed. In 192.168.1.64/27, with the router at .65, you might reserve .66 to .70 for a printer and access points and hand out .71 to .94. That is 24 leases.

Compare that number with the devices you expect, remembering that departed visitors keep their leases until they expire. A small subnet with long leases can run out while most of its devices are gone. New arrivals then fail to get an address even though the network looks quiet. Shorter leases or a larger subnet solve it.

What goes wrong

  1. Assigning the broadcast address to a device. Usually the operating system refuses, but a mismatched mask can let it through, producing odd behavior.
  2. Mask too short on one host. It believes a remote address is local, tries ARP for it and gets nothing.
  3. Mask too long on one host. It sends local traffic to the router, which may or may not hand it back.
  4. DHCP pool including fixed addresses. Leads to address conflicts.
  5. Resizing a subnet halfway. Old devices keep the old mask and old idea of the broadcast address until reconfigured or their leases renew.

A quick check

For 172.20.8.0/22: the block size in the third octet is 4. The network is 172.20.8.0, the broadcast is 172.20.11.255 and hosts run from 172.20.8.1 to 172.20.11.254, a total of 1,022. The address 172.20.9.255 is a host. If you got that right, the rule is yours. For every prefix at a glance, see the subnetting cheat sheet.

Written for 4Internet with AI writing tools and not reviewed line by line by a person. Check anything you rely on with the maker, provider or standard concerned. Report an error.

Keep reading

All 45 articles in IP Addresses & Routing →

Latest news on this topic