Subnet - Wikipedia
Subnet - Wikipedia
A subnetwork or subnet is a logical subdivision of an IP net work.[1]: 1, 16 The pract ice of dividing
a net work int o t wo or more net works is called subnetting.
Comput ers t hat belong t o t he same subnet are addressed wit h an ident ical group of it s most -
significant bit s of t heir IP addresses. This result s in t he logical division of an IP address int o t wo
fields: t he network number or routing prefix, and t he rest field or host identifier. The rest field is an
ident ifier for a specific host or net work int erface.
The routing prefix may be expressed as t he first address of a net work, writ t en in Classless Int er-
Domain Rout ing (CIDR) not at ion, followed by a slash charact er (/), and ending wit h t he bit -lengt h
of t he prefix. For example, 198.51.100.0/24 is t he prefix of t he Int ernet Prot ocol version 4
net work st art ing at t he given address, having 24 bit s allocat ed for t he net work prefix, and t he
remaining 8 bit s reserved for host addressing. Addresses in t he range 198.51.100.0 t o
198.51.100.255 belong t o t his net work, wit h 198.51.100.255 as t he subnet broadcast address.
The IPv6 address specificat ion 2001:db8::/32 is a large address block wit h 296 addresses, having
a 32-bit rout ing prefix.
For IPv4, a net work may also be charact erized by it s subnet mask or netmask, which is t he
bit mask t hat , when applied by a bit wise AND operat ion t o any IP address in t he net work, yields
t he rout ing prefix. Subnet masks are also expressed in dot -decimal not at ion like an IP address.
For example, t he prefix 198.51.100.0/24 would have t he subnet mask 255.255.255.0.
Traffic is exchanged bet ween subnet s t hrough rout ers when t he rout ing prefixes of t he source
address and t he dest inat ion address differ. A rout er serves as a logical or physical boundary
bet ween t he subnet s.
The benefit s of subnet t ing an exist ing net work vary wit h each deployment scenario. In t he
address allocat ion archit ect ure of t he Int ernet using CIDR and in large organizat ions, efficient
allocat ion of address space is necessary. Subnet t ing may also enhance rout ing efficiency, or have
advant ages in net work management when subnet s are administ rat ively cont rolled by different
ent it ies in a larger organizat ion. Subnet s may be arranged logically in a hierarchical archit ect ure,
part it ioning an organizat ion's net work address space int o a t ree-like rout ing st ruct ure, or ot her
st ruct ures, such as meshes.
Comput ers part icipat ing in an IP net work have at least one net work address. Usually, t his
address is unique t o each device and can eit her be configured aut omat ically by a net work service
wit h t he Dynamic Host Configurat ion Prot ocol (DHCP), manually by an administ rat or, or
aut omat ically by t he operat ing syst em wit h st at eless address aut oconfigurat ion.
An address fulfills t he funct ions of ident ifying t he host and locat ing it on t he net work in
dest inat ion rout ing. The most common net work addressing archit ect ure is Int ernet Prot ocol
version 4 (IPv4), but it s successor, IPv6, has been increasingly deployed since approximat ely
2006. An IPv4 address consist s of 32 bit s. An IPv6 address consist s of 128 bit s. In bot h
archit ect ures, an IP address is divided int o t wo logical part s, t he network prefix and t he host
identifier. All host s on a subnet have t he same net work prefix. This prefix occupies t he most -
significant bit s of t he address. The number of bit s allocat ed wit hin a net work t o t he prefix may
vary bet ween subnet s, depending on t he net work archit ect ure. The host ident ifier is a unique
local ident ificat ion and is eit her a host number on t he local net work or an int erface ident ifier.
This addressing st ruct ure permit s t he select ive rout ing of IP packet s across mult iple net works
via special gat eway comput ers, called rout ers, t o a dest inat ion host if t he net work prefixes of
originat ion and dest inat ion host s differ, or sent direct ly t o a t arget host on t he local net work if
t hey are t he same. Rout ers const it ut e logical or physical borders bet ween t he subnet s, and
manage t raffic bet ween t hem. Each subnet is served by a designat ed default rout er but may
consist int ernally of mult iple physical Et hernet segment s int erconnect ed by net work swit ches.
The rout ing prefix of an address is ident ified by t he subnet mask, writ t en in t he same form used
for IP addresses. For example, t he subnet mask for a rout ing prefix t hat is composed of t he
most -significant 24 bit s of an IPv4 address is writ t en as 255.255.255.0.
The modern st andard form of specificat ion of t he net work prefix is CIDR not at ion, used for bot h
IPv4 and IPv6. It count s t he number of bit s in t he prefix and appends t hat number t o t he address
aft er a slash (/) charact er separat or. This not at ion was int roduced wit h Classless Int er-Domain
Rout ing (CIDR).[2] In IPv6 t his is t he only st andards-based form t o denot e net work or rout ing
prefixes.
For example, t he IPv4 net work 192.0.2.0 wit h t he subnet mask 255.255.255.0 is writ t en as
192.0.2.0/24, and t he IPv6 not at ion 2001:db8::/32 designat es t he address 2001:db8:: and it s
net work prefix consist ing of t he most significant 32 bit s.
In classful net working in IPv4, before t he int roduct ion of CIDR, t he net work prefix could be
direct ly obt ained from t he IP address, based on it s highest -order bit sequence. This det ermined
t he class (A, B, C) of t he address and t herefore t he subnet mask. Since t he int roduct ion of CIDR,
however, t he assignment of an IP address t o a net work int erface requires t wo paramet ers, t he
address and a subnet mask.
Given an IPv4 source address, it s associat ed subnet mask, and t he dest inat ion address, a rout er
can det ermine whet her t he dest inat ion is on a locally connect ed net work or a remot e net work.
The subnet mask of t he dest inat ion is not needed, and is generally not known t o a rout er.[3] For
IPv6, however, on-link det erminat ion is different in det ail and requires t he Neighbor Discovery
Prot ocol (NDP).[4][5] IPv6 address assignment t o an int erface carries no requirement of a
mat ching on-link prefix and vice versa, wit h t he except ion of link-local addresses.
Since each locally connect ed subnet must be represent ed by a separat e ent ry in t he rout ing
t ables of each connect ed rout er, subnet t ing increases rout ing complexit y. However, by careful
design of t he net work, rout es t o collect ions of more dist ant subnet s wit hin t he branches of a
t ree hierarchy can be aggregat ed int o a supernet work and represent ed by single rout es.
The following example shows t he separat ion of t he net work prefix and t he host ident ifier from
an address (192.0.2.130) and it s associat ed /24 subnet mask (255.255.255.0). The operat ion is
visualized in a t able using binary address format s.
Binary form Dot-decimal notation
The result of t he bit wise AND operat ion of IP address and t he subnet mask is t he net work prefix
192.0.2.0. The host part , which is 130, is derived by t he bit wise AND operat ion of t he address
and t he ones' complement of t he subnet mask.
Subnetting
Subnet t ing is t he process of designat ing some high-order bit s from t he host part as part of t he
net work prefix and adjust ing t he subnet mask appropriat ely. This divides a net work int o smaller
subnet s. The following diagram modifies t he above example by moving 2 bit s from t he host part
t o t he net work prefix t o form four smaller subnet s each one quart er of t he previous size.
The first subnet obt ained from subnet t ing a larger net work has all bit s in t he subnet bit group
set t o zero. It is t herefore called subnet zero.[7] The last subnet obt ained from subnet t ing a
larger net work has all bit s in t he subnet bit group set t o one. It is t herefore called t he all-ones
subnet.[8]
The IETF originally discouraged t he product ion use of t hese t wo subnet s. When t he prefix lengt h
is not available, t he larger net work and t he first subnet have t he same address, which may lead t o
confusion. Similar confusion is possible wit h t he broadcast address at t he end of t he last subnet .
Therefore, reserving t he subnet values consist ing of all zeros and all ones on t he public Int ernet
was recommended,[9] reducing t he number of available subnet s by t wo for each subnet t ing. This
inefficiency was removed, and t he pract ice was declared obsolet e in 1995 and is only relevant
when dealing wit h legacy equipment .[10]
Alt hough t he all-zeros and t he all-ones host values are reserved for t he net work address of t he
subnet and it s broadcast address, respect ively, in syst ems using CIDR all subnet s are available in
a subdivided net work. For example, a /24 net work can be divided int o sixt een usable /28
net works. Each broadcast address, i.e. *.15, *.31, …, *.255, reduces only t he host count in each
subnet s.
The remaining bit s aft er t he subnet bit s are used for addressing host s wit hin t he subnet . In t he
above example, t he subnet mask consist s of 26 bit s, making it 255.255.255.192, leaving 6 bit s
for t he host ident ifier. This allows for 62 host combinat ions (26−2).
In general, t he number of available host s on a subnet is 2h−2, where h is t he number of bit s used
for t he host port ion of t he address. The number of available subnet s is 2n, where n is t he number
of bit s used for t he net work port ion of t he address.
There is an except ion t o t his rule for 31-bit subnet masks,[11] which means t he host ident ifier is
only one bit long for t wo permissible addresses. In such net works, usually point -t o-point links,
only t wo host s (t he endpoint s) may be connect ed and a specificat ion of net work and broadcast
addresses is not necessary.
Subnet masks and IP Addresses
Mask IP Addresses Hosts Netmask
/31 2 2 255.255.255.254
/30 4 2 255.255.255.252
/29 8 6 255.255.255.248
/28 16 14 255.255.255.240
/27 32 30 255.255.255.224
/26 64 62 255.255.255.192
A compliant IPv6 subnet always uses addresses wit h 64 bit s in t he host ident ifier.[12] Given t he
address size of 128 bit s, it t herefore has a /64 rout ing prefix. Alt hough it is t echnically possible
t o use smaller subnet s,[13] t hey are impract ical for local area net works based on Et hernet
t echnology, because 64 bit s are required for st at eless address aut oconfigurat ion.[14] The
Int ernet Engineering Task Force recommends t he use of /127 subnet s for point -t o-point links,
which have only t wo host s.[15][16]
IPv6 does not implement special address format s for broadcast t raffic or net work numbers,[17]
and t hus all addresses in a subnet are accept able for host addressing. The all-zeroes address is
reserved as t he subnet -rout er anycast address.[18] The subnet rout er anycast address is t he
lowest address in t he subnet , so it looks like t he “net work address”. If a rout er has mult iple
subnet s on t he same link, t hen it has mult iple subnet rout er anycast addresses on t hat link.[19]
The first and last address in any net work or subnet is not allowed t o be assigned t o any individual
host .
In t he past , t he recommended allocat ion for an IPv6 cust omer sit e was an address space wit h a
48-bit (/48) prefix.[20] However, t his recommendat ion was revised t o encourage smaller blocks,
for example using 56-bit prefixes.[21] Anot her common allocat ion size for resident ial cust omer
net works has a 64-bit prefix.
See also
Further reading