Domain IP Lookup

Публичное и приватное адресное пространство

Публичный IP

192.0.2.10

глобально уникален: маршрутизируется отовсюду

Приватные диапазоны

10.0.0.0/8172.16.0.0/12192.168.0.0/16

не маршрутизируются в публичном интернете

Основы DNS

What Is CIDR? Classless Routing, Prefixes and Aggregation

6 мин чтения

A route such as 203.0.113.0/24 looks like shorthand, but the idea behind it eased a crisis that, in the early 1990s, appeared likely to stall the internet's growth. This article covers why the original classful addressing failed, what a prefix actually states, how neighboring blocks merge into one route, and why a router always prefers the most specific route it knows. For the arithmetic of splitting a block into subnets, the subnet calculator is quicker than any explanation; the focus here is how the system works and why.

The problem with Class A, B and C

The original IPv4 plan, defined in RFC 791, sorted networks into classes by the leading bits of an address. As RFC 4632 recounts, Class A allowed 128 networks of about 16.7 million addresses each, Class B allowed 16,384 networks of 65,536 addresses, and Class C allowed about 2.1 million networks of 254 usable hosts. Nothing sat between 254 and 65,534 hosts.

A mid-sized organization was stuck. A Class C was too small and a Class B was too large for most organizations, yet Class B was the best fit available for use with subnetting, so demand for Class B numbers ran away. In November 1991 the IETF created the ROAD (Routing and Addressing) group. By January 1992 it had named three problems: the Class B space was running out, routing tables were growing beyond what software, hardware and operators could manage, and the 32-bit address space would eventually be exhausted. Its work produced RFC 1338 and then RFC 1519 (September 1993).

CIDR, Classless Inter-Domain Routing, was designed to ease the first two problems, not the third. RFC 4632, the 2006 revision, says the plan was meant as a short-term response lasting roughly three to five years while a longer-term solution was found. More than thirty years later it is still the notation routers and cloud consoles use.

What a prefix states

In CIDR an address block is written as an address, a slash and a prefix length: the number of leading bits that identify the network. The remaining bits identify hosts inside it. 192.0.2.0/24 fixes 24 bits and leaves 8, so the block holds 2^8 = 256 addresses. Each bit added to the prefix halves the block; each bit removed doubles it. A classful network was just a block whose prefix length was forced by its first bits, always /8, /16 or /24. CIDR removed the forcing, so an organization that needs about a thousand addresses can be given a /22, which holds 1,024, instead of a Class B.

PrefixAddressesTypical role
/816,777,216The old Class A size
/1665,536The old Class B size
/221,024A mid-sized site, a size the class system could not express
/24256The old Class C size, and a common LAN size
/304A traditional point-to-point link with 2 usable hosts
/312A point-to-point link under RFC 3021, with both addresses usable
/321A single host, or a route to exactly one address

Aggregation: one route instead of many

The other half of CIDR's purpose was routing. If a provider holds one large block and hands out pieces of it to customers, the rest of the internet needs only one route to the whole block instead of one per customer. RFC 4632 says prefixes are intended to roughly follow the underlying internet topology so that aggregation is possible, which is why they are generally assigned along provider-to-customer lines.

Aggregation only works when blocks line up. Two adjacent /24 blocks merge into a /23 only if the first one starts on an even boundary. 192.168.0.0/24 and 192.168.1.0/24 combine into 192.168.0.0/23. 192.168.1.0/24 and 192.168.2.0/24 cannot, because no /23 begins at 192.168.1.0. The smallest single block covering both is 192.168.0.0/22, which also takes in 192.168.0.0/24 and 192.168.3.0/24, addresses you may not own. That alignment rule is the practical reason to hand out addresses in power-of-two blocks from the start of a network plan.

Longest match: why the most specific route wins

When routes overlap, the router needs a tiebreak. RFC 4632 states that forwarding on the internet is done on a longest-match basis: of all the routes whose prefix contains the destination, the one with the longest prefix is used. Suppose a table holds 10.0.0.0/8 via router A, 10.1.0.0/16 via router B and 10.1.2.0/24 via router C.

  • A packet for 10.1.2.9 matches all three routes and follows the /24 to C.
  • A packet for 10.1.9.9 matches the /8 and the /16, and follows the /16 to B.
  • A packet for 10.9.9.9 matches only the /8 and goes to A.

RFC 4632 (section 5.1) adds two rules. A network reachable through several providers must announce its own prefix explicitly instead of being hidden inside one provider's aggregate. And a router that generates an aggregate must discard packets that match the aggregate but none of its more specific routes, otherwise traffic for unreachable parts of the block can loop.

Details that still trip people up

  • Usable hosts. A block of 2^(32−n) addresses normally loses two: the network address and the broadcast address. A /30 therefore has two usable hosts. RFC 3021 allows /31 prefixes on point-to-point links, where both addresses are usable.
  • Private ranges are CIDR blocks too. RFC 1918 reserves 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. The middle block runs from 172.16.0.0 to 172.31.255.255 only, so an address such as 172.32.0.1 is public.
  • Subnet zero. RFC 950 (1985), written for the classful era, advised against assigning subnets whose subnet field was all zeros or all ones. RFC 1878 (1995) calls that practice obsolete, and modern software can use every definable subnet.
  • IPv6 uses a similar notation. RFC 4291 requires 64-bit interface identifiers for all unicast addresses except those starting with the binary value 000, so an ordinary IPv6 subnet is a /64 and address planning happens in the bits above it.

Ключевой вывод

A prefix length says how many leading bits are the network. Everything else follows from that: blocks of any power-of-two size, aggregation of aligned neighbors, and forwarding by the longest matching prefix.

Sources and further reading

Нужно проверить публичные DNS-адреса домена? Воспользуйтесь инструментом Domain IP Lookup.

Бесплатные инструменты по этой теме

what is cidrcidr notationroute aggregationlongest prefix match

Часто задаваемые вопросы

Читайте также

Публичное и приватное адресное пространство

Публичный IP

192.0.2.10

глобально уникален: маршрутизируется отовсюду

Приватные диапазоны

10.0.0.0/8172.16.0.0/12192.168.0.0/16

не маршрутизируются в публичном интернете

Основы DNS

Публичные и частные IP-адреса: в чём разница

У вашего устройства одновременно два адреса, и только один из них существует в интернете. Почему так и что означают зарезервированные диапазоны.

3 мин чтения

Две схемы адресации, работающие бок о бок

IPv4

192.0.2.10

32 бита, ~4,3 млрд адресов, исчерпаны

IPv6

2606:4700::6810:84e5

128 бит, 340 ундециллионов адресов

Инфраструктура и эксплуатация

Исчерпание IPv4 и медленный путь к IPv6

Новые адреса IPv4 закончились в мире много лет назад. Вот что на самом деле поддерживало работу сети с тех пор и почему переход до сих пор не завершён.

3 мин чтения

Две схемы адресации, работающие бок о бок

IPv4

192.0.2.10

32 бита, ~4,3 млрд адресов, исчерпаны

IPv6

2606:4700::6810:84e5

128 бит, 340 ундециллионов адресов

Основы DNS

Что такое IP-адрес: IPv4 и IPv6 простыми словами

Числовая метка за каждым сайтом, сервером и телефоном в интернете: что она означает, как её читать и почему существуют две несовместимые версии.

4 мин чтения