CIDR Notation

http://blog.sina.com.cn/s/blog_5d76edd80101e48f.html

What is CIDR Notation

Classless Inter Domain Routing (CIDR) is a method for assigning IP addresses without using the standard IP address classes like Class A, Class B or Class C.

In CIDR notation, an IP address is represented as A.B.C.D /n, where "/n" is called the IP prefix or network prefix. The IP prefix identifies the number of significant bits used to identify a network. For example, 192.9.205.22 /18 means, the first 18 bits are used to represent the network and the remaining 14 bits are used to identify hosts. Common prefixes are 8, 16, 24, and 32.

Refer to the following page for the CIDR to Netmask Translation Table.

 

CIDR
Netmask (Dot Notation)Number of Hosts
/1128.0.0.0 
/2192.0.0.0 
/3224.0.0.0 
/4240.0.0.0 
/5248.0.0.0 
/6252.0.0.0 
/7254.0.0.0 
/8255.0.0.0 
/9255.128.0.0 
/10255.192.0.0 
/11255.224.0.0 
/12255.240.0.0 
/13255.248.0.0 
/14255.252.0.0 
/15255.254.0.0 
/16255.255.0.0 
/17255.255.128 
/18255.255.192.0 
/19255.255.224.0 
/20255.255.240.0 
/21255.255.248.0 
/22255.255.252.0 
/23255.255.254.0 
/24255.255.255.0256
/25255.255.255.128128
/26255.255.255.19264
/27255.255.255.22432
/28255.255.255.24016
/29255.255.255.2488
/30255.255.255.2524
/31255.255.255.2542
/32255.255.255.2551

CIDR notation is a compact specification of an Internet Protocol address and its associated routing prefix. Classless Inter-Domain Routing (CIDR) is an Internet Protocol (IP) address allocation and route aggregation methodology[1] used within the Internet addressing architecture that replaced the IPv4 classful network organization of the IP address space. It is used also for IPv6 networking, the next generation of the IP addressing architecture.

CIDR notation is constructed from the IP address and the prefix size, the latter being equivalent to the number of leading 1 bits in the routing prefix mask. The IP address is expressed according to the standards of IPv4 or IPv6. It is followed by a separator character, the slash (/) character, and the prefix size expressed as a decimal number.

The address may denote a single, distinct, interface address or the beginning address of an entire network. In the latter case the CIDR notation specifies the address block allocation of the network. The maximum size of the network is given by the number of addresses that are possible with the remaining, least-significant bits below the prefix. This is often called the host identifier.

For example:

  • 198.51.100.1/24 represents the given IPv4 address and its associated routing prefix 198.51.100.0, or equivalently, its subnet mask 255.255.255.0.
  • the IPv4 block 198.51.100.0/22 represents the 1024 IPv4 addresses from 198.51.100.0 to 198.51.103.255.
  • the IPv6 block 2001:db8::/48 represents the IPv6 addresses from 2001:db8:0:0:0:0:0:0 to 2001:db8:0:ffff:ffff:ffff:ffff:ffff.
  • ::1/128 represents the IPv6 loopback address. Its prefix size is 128, i.e. the size of the address itself, indicating that this facility consists of only this one address.

Before CIDR notation, IPv4 networks usually used dot-decimal notation, an alternative representation which uses the network address followed by the network's subnet mask. Thus, The CIDR notation 198.51.100.0/24 would be written as 198.51.100.0/255.255.255.0

The number of addresses of a subnet defined by the mask or prefix can be calculated as 2address size - prefix size, in which the address size for IPv6 is 128 and 32 for IPv4. For example, in IPv4, a prefix size of /29 gives: 232-29 = 23 = 8 addresses.

However, because at least one of these addresses is typically used for a gateway to other subnets, and because certain addresses are reserved as broadcast addresses, the number of addresses available for hosts is usually smaller.

http://wenku.baidu.com/view/736f9e1fb7360b4c2e3f649f.html


IP 编址问题的演进
划分子网在一定程度上缓解了因特网在发展中遇到的困难。然而在 1992 年因特网仍然面临三个
必须尽早解决的问题,这就是:
B 类地址在 1992 年已分配了近一半,眼看就要在 1994 年 3 月全部分配完毕!
因特网主干网上的路由表中的项目数急剧增长(从几千个增长到几万个)。
整个 IPv4 的地址空间最终将全部耗尽。
1987 年,RFC 1009 就指明了在一个划分子网的网络中可同时使用几个不同的子网掩
码。使用变长子网掩码 VLSM (Variable Length Subnet Mask)可进一步提高 IP 地址资
源的利用率。
在 VLSM 的基础上又进一步研究出无分类编址方法,它的正式名字是无分类域间路
由选择 CIDR (Classless Inter-Domain Routing)。
CIDR 最主要的特点
CIDR 消除了传统的 A 类、B 类和 C 类地址以及划分子网的概念,因而可以更加有
效地分配 IPv4 的地址空间。
CIDR 使用各种长度的“网络前缀” (network-prefix)来代替分类地址中的网络号和子网
号。
IP 地址从三级编址(使用子网掩码)又回到了两级编址。
无分类的两级编址
无分类的两级编址的记法是:
IP 地址 ::= {<网络前缀>, <主机号>}
CIDR 还使用“斜线记法”(slash notation),它又称为CIDR 记法,即在 IP 地址后面加上
一个斜线“/”,然后写上网络前缀所占的比特数(这个数值对应于三级编址中子网掩码
中比特 1 的个数)。
CIDR 将网络前缀都相同的连续的 IP 地址组成“CIDR 地址块”。
CIDR 地址块
128.14.32.0/20 表示的地址块共有 212 个地址(因为斜线后面的 20 是网络前缀的比
特数,所以主机号的比特数是 12)。
这个地址块的起始地址是 128.14.32.0。
在不需要指出地址块的起始地址时,也可将这样的地址块简称为“/20 地址块”。
128.14.32.0/20 地址块的最小地址:128.14.32.0
128.14.32.0/20 地址块的最大地址:128.14.32.255

全 0 和全 1 的主机号地址一般不使用。
128.14.32.0/20 表示的地址(212 个地址)
10000000 00001110 00100000 00000000
10000000 00001110 00100000 00000001
10000000 00001110 00100000 00000010
10000000 00001110 00100000 00000011
10000000 00001110 00100000 00000100
10000000 00001110 00100000 00000101
10000000 00001110 00101111 11111011
10000000 00001110 00101111 11111100
10000000 00001110 00101111 11111101
10000000 00001110 00101111 11111110
10000000 00001110 00101111 11111111
… …
所有地址
的20 bit
前缀都是
一样的
最小地址
最大地址
路由聚合(route aggregation)
一个 CIDR 地址块可以表示很多地址,这种地址的聚合常称为路由聚合,它使得路由
表中的一个项目可以表示很多个(例如上千个)原来传统分类地址的路由。
路由聚合也称为构成超网(supernetting)。
CIDR 虽然不使用子网了,但仍然使用“掩码”这一名词(但不叫子网掩码)。
对于 /20 地址块,它的掩码是 20 个连续的 1。 斜线记法中的数字就是掩码中 1 的
个数。
10.0.0.0/10 可简写为 10/10,也就是将点分十进制中低位连续的 0 省略。
10.0.0.0/10 隐含地指出 IP 地址 10.0.0.0 的掩码是 255.192.0.0。此掩码可表示为
CIDR 记法的其他形式
10.0.0.0/10 可简写为 10/10,也就是将点分十进制中低位连续的 0 省略。
10.0.0.0/10 相当于指出 IP 地址 10.0.0.0 的掩码是 255.192.0.0,即
11111111 11000000 00000000 00000000
网络前缀的后面加一个星号 * 的表示方法,如 00001010 00*,在星号 * 之前是网络
前缀,而星号 * 表示 IP 地址中的主机号,可以是任意值。
构成超网
前缀长度不超过 23 bit 的 CIDR 地址块都包含了多个 C 类地址。
这些 C 类地址合起来就构成了超网。
CIDR 地址块中的地址数一定是 2 的整数次幂。
网络前缀越短,其地址块所包含的地址数就越多。而在三级结构的IP 地址中,划分子
网是使网络前缀变长。

CIDR 作用
将有类别的寻址方式替换成更灵活、浪费更少的无类别方案。
加强了路由聚合,即超网(supernetting)。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值