3 IP Addressing and Subnets
Learn how IPv4 addresses, subnet prefixes, private and public ranges, gateways, and deliberate address planning work together to support network communication.
IPv4 addresses and their parts
An identifies a device on an IP network and helps determine where traffic should be sent. An is a 32-bit number, usually written as four decimal octets separated by periods; each ranges from 0 to 255. For example, 192.168.10.25 is an . The address and its together identify both the local network and the device’s address within that network.
Subnet masks, prefixes, and address counts
A marks the network portion of an : the network bits are 1s, followed by host bits that are 0s. For example, 255.255.255.0 has 24 network bits and 8 host bits. expresses the number of network bits as a prefix, so this mask is written /24. Thus, 192.168.10.25/24 belongs to the 192.168.10.0/24 subnet.
The total number of addresses in a subnet is determined by its prefix length:
Here, is the prefix length. In a typical IPv4 subnet, the first address identifies the subnet and the last is the , so neither is assigned to ordinary devices. For 192.168.10.0/24, there are 256 total addresses: .0 is the , .255 is the , and .1 through .254 are available for host interfaces.
A smaller subnet can conserve address space. A /26 contains 64 total addresses, conventionally 62 usable for hosts. The usual calculation that excludes the first and last addresses has exceptions, such as /31 point-to-point links. Choose a prefix that provides enough addresses for the devices and planned growth.
Private and public IPv4 addresses
Private addresses are reserved for private networks and can be reused by different homes and organizations. They are not globally unique and are not routed across the public Internet. The reserved IPv4 ranges are:
10.0.0.0/8172.16.0.0/12, covering172.16.0.0through172.31.255.255192.168.0.0/16
A router commonly uses to let devices using private addresses access Internet services. Public addresses, by contrast, are globally unique addresses used for Internet routing. An organization generally receives them through its Internet service provider or another address-allocation authority.
Using a
A device sends traffic directly to destinations it determines are on its local subnet. For a destination outside that subnet, it sends the traffic to its , usually the local router’s address on the same subnet. The gateway forwards traffic toward other networks.
For example, a device at 192.168.10.25/24 might use 192.168.10.1 as its gateway. To communicate beyond its local subnet, a host needs a valid local address, subnet prefix, and gateway.
Planning a network address space
A small home or office network might use 192.168.10.0/24. One possible allocation is:
Subnet:
192.168.10.0/24Router and :
192.168.10.1Reserved addresses for infrastructure or static devices:
192.168.10.2–192.168.10.49for automatically configured devices:
192.168.10.100–192.168.10.199:
192.168.10.255
To plan an address space, first estimate how many devices each subnet must support, then choose a prefix with enough host addresses. Assign each subnet a distinct, non-overlapping range. Reserve addresses for gateways and devices that need stable addresses, and keep dynamically assigned DHCP addresses in a separate pool.
Check that the chosen private range does not conflict with another network the organization must connect to, such as a remote office or VPN. A DHCP server can distribute the address, , and gateway settings to client devices automatically.