Subnet masks (IPv4) and prefixes (IPv6)
Subnet masks (IPv4) and prefix lengths (IPv6) identify a range of IP addresses that are on the same network.
IPv4 subnet masks
All IP addresses are divided into portions. One part identifies the network (the network number) and the other part identifies the specific machine or host within the network (the host number). Subnet masks (IPv4) and prefixes (IPv6) identify the range of IP addresses that make up a subnet, or group of IP addresses on the same network. For example, a subnet can be used to identify all the machines in a building, department, geographic location, or on the same local area network (LAN).
Dividing an organization's network into subnets allows it to be connected to the Internet with a single shared network address. Subnet masks and prefixes are used when a host is attempting to communicate with another system. If the system is on the same network or subnet, it attempts to find that address on the local link. If the system is on a different network, the packet is sent to a gateway that then routes the packet to the correct IP address. This routing is called Classless-InterDomain Routing (CIDR).
In IPv4, the subnet
mask 255.255.255.0
is 32 bits and consists of four
8-bit octets. The address: 10.10.10.0
subnet mask 255.255.255.0
means
that the subnet is a range of IP addresses from 10.10.10.0
- 10.10.10.255.
The prefix-length in IPv6 is the
equivalent of the subnet mask in IPv4. However, rather than being
expressed in four octets like it is in IPv4, it is expressed as an
integer between 1 through 128. For example: 2001:db8:abcd:0012::0/64
specifies
a subnet with a range of IP addresses from: 2001:db8:abcd:0012:0000:0000:0000:0000
- 2001:db8:abcd:0012:ffff:ffff:ffff:ffff
. The portion
in bold is called the network portion of the IP address, or the prefix.
The non-bold portion is called the host portion of the IP address,
since it identifies an individual host on the network.
IPv6 addresses
- Network address - the first three groupings of numbers (first 48 bits) in the subnet mask
- Subnet address - the fourth grouping of numbers (the 49th through 64th bits) in the subnet mask
- Device address - the last four groupings of numbers (the last 64 bits) in the subnet mask
2001:db8:abcd:0012:0000:0000:0000:0000
The
network address is 2001:db8:abcd
, and the subnet
address is 12
(using the short form notation and
eliminating the leading zeroes). Together, these two groupings are
the IPv6 prefix. The device address in the example is 0000:0000:0000:0000
./64
specified
like this: 2001:db8:abcd:0012::/64
tells the system
to divide the network into 64 subnetworks. Each subnetwork contains
1/64th of the devices on the network. Table 1 shows
the resulting network ranges for prefix lengths of IPv6 addresses. Expanded notation of IPv6 address at start of the range | IPv6 address (condensed notation) | IPv6 Address with prefix length | Device range in subnetwork |
---|---|---|---|
2001:0DB8:ABCD:0012:0000:0000:0000:0000 |
2001:DB8:ABCD:12:: |
2001:db8:abcd:0012::0/64 |
2001:0DB8:ABCD:0012:0000:0000:0000:0000
- 2001:0DB8:ABCD:0012:FFFF:FFFF:FFFF:FFFF |
2001:0DB8:ABCD:0012:0000:0000:0000:0000 |
2001:DB8:ABCD:12:: |
2001:db8:abcd:0012::0/80 |
2001:0DB8:ABCD:0012:0000:0000:0000:0000
- 2001:0DB8:ABCD:0012:0000:FFFF:FFFF:FFFF |
2001:0DB8:ABCD:0012:0000:0000:0000:0000 |
2001:DB8:ABCD:12:: |
2001:db8:abcd:0012::0/96 |
2001:0DB8:ABCD:0012:0000:0000:0000:0000
- 2001:0DB8:ABCD:0012:0000:0000:FFFF:FFFF |
2001:0DB8:ABCD:0012:0000:0000:0000:0000 |
2001:DB8:ABCD:12:: |
2001:db8:abcd:0012::0/112 |
2001:0DB8:ABCD:0012:0000:0000:0000:0000
- 2001:0DB8:ABCD:0012:0000:0000:0000:FFFF |
2001:0DB8:ABCD:0012:0000:0000:0000:0000 |
2001:DB8:ABCD:12:: |
2001:db8:abcd:0012::0/128 |
2001:0DB8:ABCD:0012:0000:0000:0000:0000
- 2001:0DB8:ABCD:0012:0000:0000:0000:0000 |