Classless Inter-Domain Routing: Difference between revisions

Content deleted Content added
m Reverted 1 edit by 2806:370:202D:1D8E:2337:EBE4:5C4D:C04F (talk) to last revision by Johnuniq
IPv6 CIDR blocks: hyphen missing from compound modifier; grammatical number
 
(39 intermediate revisions by 29 users not shown)
Line 1:
{{Short description|Method for IP address allocation and routing}}
{{Redirect|CIDR}}
{{Copy edit |reason=direct links to RFCs (using {{tl|IETF RFC}} that its documentation says is not for that usage) rather than correctly citing these RFCs |date=August 2025}}
 
{{Use American English |date=August 2025}}
{{Use mdy dates |date=August 2025}}
'''Classless Inter-Domain Routing''' ('''CIDR''' {{IPAc-en|ˈ|s|aɪ|d|ər|,_|ˈ|s|ɪ|-}}) is a method for allocating [[IP address]]es for [[IP routing]]. The [[Internet Engineering Task Force]] introduced CIDR in 1993 to replace the previous [[classful network]] addressing architecture on the [[Internet]]. Its goal was to slow the growth of [[routing table]]s on [[router (computing)|routers]] across the Internet, and to help slow the rapid [[IPv4 address exhaustion|exhaustion of IPv4 addresses]].<ref name="RFC 1518">{{cite IETF |rfc=1518 |title=An Architecture for IP Address Allocation with CIDR |author1=Y. Rekhter |author2=T. Li |date=September 1993}}</ref><ref name="RFC 1519">{{cite IETF |rfc=1519 |title=Classless Inter-Domain Routing (CIDR): an Address Assignment and Aggregation Strategy |author1=V. Fuller |author2=T. Li |author3=J. Yu |author4=K. Varadhan |date=September 1993}}</ref>
 
IP addresses are described as consisting of two groups of [[bit]]s in the address: the [[most significant bit]]s are the [[network prefix]], which identifies a whole network or [[subnet]], and the [[least significant bit|least significant]] set forms the ''host identifier'', which specifies a particular interface of a host on that network. This division is used as the basis of traffic routing between IP networks and for address allocation policies.
 
Whereas classful network design for [[IPv4]] sized the network prefix as one or more 8-bit groups, resulting in the blocks of Class A, B, or C addresses, under CIDR address space is allocated to [[Internet service provider]]s and [[end user]]s on any address-bit boundary. In [[IPv6]], however, the interface identifier has a fixed size of 64 bits by convention, and smaller subnets are never allocated to end users.
 
{{Anchor|VLSM}}CIDR is based on '''variable-length subnet masking''' ('''VLSM'''), in which network prefixes have variable length (as opposed to the fixed-length prefixing of the previous classful network design). The main benefit of this is that it grants finer control of the sizes of subnets allocated to organizations, hence slowing the exhaustion of IPv4 addresses from allocating larger subnets than needed. CIDR gave rise to a new way of writing IP addresses known as CIDR notation, in which an IP address is followed by a suffix indicating the number of bits of the prefix. Some examples of CIDR notation are the addresses {{IPaddr|192.0.2.0|24}} for IPv4 and {{IPaddr|2001:db8::|32}} for IPv6. Blocks of addresses having contiguous prefixes may be aggregated as [[supernet]]s, reducing the number of entries in the global routing table.
 
==Background==
Line 47 ⟶ 49:
The advantage of this system is that the network prefix could be determined for any IP address without any further information. The disadvantage is that networks were usually too big or too small for most organizations to use, because only three sizes were available. The smallest allocation and routing block contained 2<sup>8</sup> = 256 addresses, larger than necessary for personal or department networks, but too small for most enterprises. The next larger block contained 2<sup>16</sup> = {{gaps|65|536}} addresses, too large to be used efficiently even by large organizations. But for network users who needed more than {{gaps|65|536}} addresses, the only other size (2<sup>24</sup>) provided far too many, more than 16 million. This led to inefficiencies in address use as well as inefficiencies in routing, because it required a large number of allocated class-C networks with individual route announcements, being geographically dispersed with little opportunity for [[route aggregation]].
 
Within a decade after the invention of the [[Domain Name System]] (DNS), the classful network method was found not [[scalable]].<ref name="RFC 1517">{{cite IETF |rfc=1517 |title=Applicability Statement for the Implementation of Classless Inter-Domain Routing (CIDR) |editor=R. Hinden |date=September 1993}}</ref> This led to the development of [[subnet]]ting and CIDR. The formerly meaningful class distinctions based on the most-significant address bits were abandoned and the new system was described as ''"classless''", in contrast to the old system, which became known as ''"classful''". Routing protocols were revised to carry not just IP addresses, but also their subnet masks. Implementing CIDR required every host and router on the Internet to be reprogrammed in small ways—no small feat at a time when the Internet was entering a period of rapid growth. In 1993, the [[Internet Engineering Task Force]] published a new set of standards, {{IETF RFC|1518}} and {{IETF RFC|1519}}, to define this new principle for allocating IP address blocks and routing IPv4 packets. An updated version, {{IETF RFC|4632}}, was published in 2006.<ref name="RFC 4632">{{cite IETF |rfc=4632 |title=Classless Inter-___domain Routing (CIDR): The Internet Address Assignment and Aggregation Plan |author1=V. Fuller |author2=T. Li |date=August 2006}}</ref>
 
After a period of experimentation with various alternatives, Classless Inter-Domain Routing was based on variable-length subnet masking (VLSM), which allows each network to be divided into subnetworks of various power-of-two sizes, so that each subnetwork can be sized appropriately for local needs. Variable-length subnet masks were mentioned as one alternative in {{IETF RFC|950}}.<ref name="RFC 950 2.1">{{cite IETF |rfc=950 |title=Internet Standard Subnetting Procedure |editor1=J. Mogul |editor2=J. Postel |date=August 1985 |section=2.1}}</ref> Techniques for grouping addresses for common operations were based on the concept of cluster addressing, first proposed by Carl-Herbert Rokitansky.<ref>Carl-Herbert Rokitansky, "Internet Cluster Addressing Scheme and its Application to Public Data Networks", Proc. 9th International Conference on Computer Communication (ICCC' 88), pp. 482–491, Tel Aviv, Israel, October/November 1988</ref><ref>[http://www.ietf.org/mail-archive/web/ietf/current/msg24136.html Cluster Addressing and CIDR] in the mail archives of the IETF</ref>
Line 54 ⟶ 56:
 
==CIDR notation==
'''CIDR notation''' is a compact representation of an IP address and its associated network mask. The notation was invented by [[Phil Karn]] in the 1980s.<ref name=kantor>{{cite web |title=Re: Stupid Question maybe? |url=https://seclists.org/nanog/2018/Dec/334 |publisher=North American Network Operators Group |author=Brian Kantor |date=December 2018 |quote=/24 is certainly cleaner than 255.255.255.0. I seem to remember it was Phil Karn who in the early 80's suggested that expressing subnet masks as the number of bits from the top end of the address word was efficient, since subnet masks were always a series of ones followd by zeros with no interspersing, which was incorporated (or independently invented) about a decade later as CIDR a.b.c.d/n notation in RFC1519.}}</ref><ref name=simpson>{{cite web |title=Re: Stupid Question maybe? |url=https://seclists.org/nanog/2018/Dec/368 |publisher=North American Network Operators Group |author=William Simpson |date=December 2018 |quote=Actually, Brian is correct. Phil was w-a-y ahead of the times. But I don't remember him talking about it until the late '80s.}}</ref> CIDR notation specifies an IP address, a [[slash (punctuation)|slash]] ('/') character, and a decimal number. The decimal number is the count of consecutive leading ''1''-bits (from left to right) in the network mask. Each 1-bit denotes a bit of the address range which must remain identical to the given IP address. The IP address in CIDR notation is always represented according to the standards for IPv4 or IPv6.
 
The address may denote a specific interface address (including a host identifier, such as {{IPaddr|10.0.0.1|8}}), or it may be the beginning address of an entire network (using a host identifier of 0, as in {{IPaddr|10.0.0.0|8}} or its equivalent {{IPaddr|10|8}}). CIDR notation can even be used with no IP address at all, e.g. when referring to a {{IPaddr||24}} as a generic description of an IPv4 network that has a 24-bit prefix and 8-bit host numbers.
 
For example:
* {{IPaddr|198.51.100.14|24}} represents the IPv4 address {{IPaddr|198.51.100.14}} and its associated network prefix {{IPaddr|198.51.100.0}}, or equivalently, its subnet mask {{IPaddr||24|netmask=dotted}}, which has 24 leading ''1''-bits.
* the IPv4 block {{IPaddr|198.51.100.0|22}} represents the 1024 IPv4 addresses from {{IPaddr|198.51.100.0}} to {{IPaddr|198.51.103.255}}.
* the IPv6 block {{IPaddr|2001:db8::|48}} represents the block of IPv6 addresses from {{IPaddr|2001:db8:0:0:0:0:0:0}} to {{IPaddr|2001:db8:0:ffff:ffff:ffff:ffff:ffff}}.
Line 66 ⟶ 68:
In IPv4, CIDR notation came into wide use only after the implementation of the method, which was documented using [[dotted-decimal]] subnet mask specification after the slash, for example, {{IPaddr|192.24.12.0|22|netmask=dotted}}.<ref name="RFC 1519" /> Describing the network prefix width as a single number ({{IPaddr|192.24.12.0|22}}) was easier for network administrators to conceptualize and to calculate. It became gradually incorporated into later standards documents<ref>{{cite ietf |rfc=1878 |title=Variable Length Subnet Table For IPv4 |author1=T. Pummill |author2=B. Manning |date=December 1995}}</ref><ref>{{cite ietf |rfc=2167 |title=Referral Whois (RWhois) Protocol V1.5 |author1=S. Williamson |author2=M. Kosters |author3=D. Blacka |author4=J. Singh |author5=K. Zeilstra |date=June 1997 |quote=IP networks are also lexically hierarchical labels using the Classless Inter-Domain Routing (CIDR) notation, but their hierarchy is not easily determined with simple text manipulation; for example, 198.41.0.0/22 is a part of 198.41.0.0/16, which is a part of 198.40.0.0/15.}}</ref> and into network configuration interfaces.
 
The number of addresses of a network may be calculated as 2<sup>address length − prefix length</sup>, where ''"address length''" is 128 for IPv6 and 32 for IPv4. For example, in IPv4, the prefix length {{IPaddr||29}} gives: 2<sup>32−29</sup> = 2<sup>3</sup> = 8 addresses.
 
==Subnet masks==
A subnet mask is a [[bitmask]] that encodes the prefix length associated with an IPv4 address or network in quad-dotted notation: 32 bits, starting with a number of ''1''-bits equal to the prefix length, ending with ''0''-bits, and encoded in four-part dotted-decimal format: {{IPaddr||24|netmask=dotted}}. A subnet mask encodes the same information as a prefix length but predates the advent of CIDR. In CIDR notation, the prefix bits are always contiguous. Subnet masks were allowed by {{IETF RFC|950}}<ref name="RFC 950 2.1"/> to specify non-contiguous bits until {{IETF RFC|4632}}<ref name="RFC 4632"/>{{rp|at=Section 5.1}} stated that the mask must be left contiguous. Given this constraint, a subnet mask and CIDR notation serve exactly the same function.
 
==CIDR blocks==
CIDR is principally a bitwise, prefix-based standard for the representation of IP addresses and their routing properties. It facilitates routing by allowing blocks of addresses to be grouped into single routing table entries. These groups, commonly called CIDR blocks, share an initial sequence of bits in the binary representation of their IP addresses. IPv4 CIDR blocks are identified using a syntax similar to that of IPv4 addresses: a dotted-decimal address, followed by a slash, then a number from 0 to 32, i.e., {{IPaddr|a.b.c.d|n}}. The dotted -decimal portion is the IPv4 address. The number following the slash is the prefix length, the number of shared initial bits, counting from the most-significant bit of the address. When emphasizing only the size of a network, the address portion of the notation is usually omitted. Thus, a /20 block is a CIDR block with an unspecified 20-bit prefix.
 
An IP address is part of a CIDR block and is said to match the CIDR prefix if the initial ''n'' bits of the address and the CIDR prefix are the same. An IPv4 address is 32 bits so an ''n''-bit CIDR prefix leaves 32 − ''n''32−n bits unmatched, meaning that 2<sup>32−''n''32−n</sup> IPv4 addresses match a given ''n''-bit CIDR prefix. Shorter CIDR prefixes match more addresses, while longer prefixes match fewer. In the case of overlaid CIDR blocks, an address can match multiple CIDR prefixes of different lengths.
 
CIDR is also used for [[IPv6 address]]es and the syntax semantic is identical. The prefix length can range from 0 to 128, due to the larger number of bits in the address. However, by convention, a subnet on broadcast MAC layer networks always has 64-bit host identifiers.<ref>{{Cite IETF |rfc=7136|last=Carpenter |first=B. |last2=Jiang |first2=S. |date=February 2014 |title=Significance of IPv6 Interface Identifiers |language=en |doi-access=free }}</ref> Larger prefixes (/127) are only used on some point-to-point links between routers, for security and policy reasons.<ref>{{Cite IETF |rfc=6164 |last=Kohno |first=M. |last2=Nitzan |first2=B. |last3=Bush |first3=R. |last4=Matsuzaki |first4=Y. |last5=Colitti |first5=L. |last6=Narten |first6=T. |date=April 2011 |title=Using 127-Bit IPv6 Prefixes on Inter-Router Links |language=en}}</ref>[[File:IP Address Match.svg|400px|right]]
Line 98 ⟶ 100:
|-
|{{IPaddr|a.b.c.d|32}}
|
| +{{IPaddr|0.0.0.0|}}
|{{IPaddr|255.255.255.255|}}
| style="text-align:right;" |1
Line 386 ⟶ 388:
| style="text-align:right;" |256 A
|
| Entire IPv4 Internet, [[default route]].
|}
 
In routed subnets larger than {{IPaddr||31}} or {{IPaddr||32}}, the number of available host addresses is usually reduced by two, namely the largest address, which is reserved as the [[broadcast address]], and the smallest address, which identifies the network itself.<ref name="RFC 922">{{cite IETF |rfc=922 |title=Broadcasting Internet Datagrams in the Presence of Subnets |editor=J. Mogul |date=October 1984 |section=7}}</ref> and is reserved for solely this purpose.<ref name="RFC 1812">{{cite IETF |rfc=1812 |title=Requirements for IP Version 4 Routers |editor=F. Baker |date=June 1995 |section=4.2.3.1}}</ref>
In common usage, the first address in a subnet, all binary zero in the host identifier, is reserved for referring to the network itself, while the last address, all binary one in the host identifier, is used as a [[broadcast address]] for the network; this reduces the number of addresses available for hosts by 2. As a result, a {{IPaddr||31}} network, with one binary digit in the host identifier, would be unusable, as such a subnet would provide no available host addresses after this reduction. {{IETF RFC|3021}} creates an exception to the "host all ones" and "host all zeros" rules to make {{IPaddr||31}} networks usable for point-to-point links. {{IPaddr||32}} addresses (single-host network) must be accessed by explicit routing rules, as there is no room in such a network for a gateway.
 
In commonsuch usage, the first address in a subnet, all binary zero in the host identifier, is reserved for referring to the network itself, while the last address, all binary one in the host identifier, is used as a [[broadcast address]] for the network; this reduces the number of addresses available for hosts by 2. As a result, a {{IPaddr||31}} network, with one binary digit in the host identifier, would beis unusable, as such a subnet would provide no available host addresses after this reduction. {{IETF RFC|3021}} creates an exception to the "host all ones" and "host all zeros" rules to make {{IPaddr||31}} networks usable for point-to-point links. {{IPaddr||32}} addresses (single-host network) must be accessed by explicit routing rules, as there is no roomaddress in such a networkavailable for a gateway.
In routed subnets larger than {{IPaddr||31}} or {{IPaddr||32}}, the number of available host addresses is usually reduced by two, namely the largest address, which is reserved as the broadcast address, and the smallest address, which identifies the network itself.<ref name="RFC 922">{{cite IETF |rfc=922 |title=Broadcasting Internet Datagrams in the Presence of Subnets |editor=J. Mogul |date=October 1984 |section=7}}</ref><ref name="RFC 1812">{{cite IETF |rfc=1812 |title=Requirements for IP Version 4 Routers |editor=F. Baker |date=June 1995 |section=4.2.3.1}}</ref>
 
===IPv6 CIDR blocks===
Line 491 ⟶ 493:
| colspan="5" | '''T''' = 1,099,511,627,776
|}
The large address size of IPv6 permitted worldwide route summarization and guaranteed sufficient address pools at each site. The standard subnet size for IPv6 networks is a {{IPaddr||64}} block, which is required for the operation of [[IPv6 stateless address autoconfiguration|stateless address autoconfiguration]].<ref name="RFC 4862">{{IETF RFC|4862}}</ref> At first, the IETF recommended in {{IETF RFC|3177}} as a best practice that all end sites receive a {{IPaddr||48}} address allocationallocations,<ref name="RFC 3177">{{cite IETF |rfc=3177 |title=IAB/IESG Recommendation on IPv6 Address Allocations to Sites |publisher=IAB/IESG |date=September 2001}}</ref> but criticism and reevaluation of actual needs and practices has led to more flexible allocation recommendations in {{IETF RFC|6177}}<ref name="RFC 6177">{{cite IETF |rfc=6177 |title=IPv6 Address Assignment to End Sites |author=T. Narten |author2=G. Huston |author3=L. Roberts |date=March 2011}}</ref> suggesting a significantly smaller allocation for some sites, such as a {{IPaddr||56}} block for residential networks.
 
This '''IPv6 subnetting reference''' lists the sizes for IPv6 [[subnetwork]]s. Different types of network links may require different subnet sizes.<ref>{{cite web|url=http://www.getipv6.info/index.php/IPv6_Addressing_Plans |title=ARIN IPv6 Addressing Plans |publisher=Getipv6.info |date=2016-03-25 |access-date=2018-03-12}}</ref> The subnet mask separates the bits of the network identifier prefix from the bits of the interface identifier. Selecting a smaller prefix size results in fewer number of networks covered, but with more addresses within each network.<ref>{{cite web |url=https://www.ripe.net/info/info-services/addressing.html |title=RIPE IP Allocation Rates |archive-url=https://web.archive.org/web/20110203130851/http://ripe.net/info/info-services/addressing.html |archive-date=2011-02-03}}</ref>
 
2001:0db8:0123:4567:89ab:cdef:1234:5678
Line 516 ⟶ 518:
|||| |||| |||| |||64 Single LAN; default prefix size for [[IPv6#Stateless_address_autoconfiguration_(SLAAC)|SLAAC]]
|||| |||| |||| ||60 Some (very limited) [[6rd]] deployments (/60 = 16 /64 blocks)
|||| |||| |||| |56 Minimal end sites-site assignment;<ref name="RFC 6177"/> e.g. [[home network]] (/56 = 256 /64 blocks)
|||| |||| |||| 52 /52 block = 4096 /64 blocks
|||| |||| |||48 Typical assignment for larger sites (/48 = 65536 /64 blocks)
Line 532 ⟶ 534:
 
==Numerical interpretation==
Topologically, the set of subnets described by CIDR represent a [[Cover (topology)|cover]] of the corresponding address space. The interval described by the notation <math>X/n</math> numerically corresponds to addresses of the form (for IPv4) <math>[x \cdot 2^{32-n}, x \cdot 2^{32-n} + 2^{32-n} - 1]</math> (for IPv4) and <math>[x \cdot 2^{128n}, x \cdot 2^{128n} + 2^{128-n} - 1]</math> (for IPv6), where <math>X = x \cdot 2^{32-n}</math> and <math>X = x \cdot 2^{128-n}</math> has the lower <math>n</math> bits set to 0. (For IPv6, substitute 128.) For a fixed <math>n</math>, the set of all <math>X/n</math> subnets constitute a [[Partition of a set|partition]], that is a cover of non-overlapping sets. Increasing <math>n</math> yields finer and finer subpartitions. Thus two subnets <math>X/n</math> and <math>Y/m</math> are either disjoint or one is a subnet of the other.
 
==Prefix aggregation==