IPv4 subnetting reference

The netmask, network mask or subnet mask is a bit mask that specifies the network protocol IPv4 in the description of IP networks, how many bits at the beginning of the shown IP address the network prefix. For IPv6, it is called the prefix length.

In conjunction with the IP address of a device, the subnet mask defines which IP addresses of this unit will search in its own network and which could reach it via routers in other networks. So you separate the IP address into a network part ( network prefix ) and a piece of equipment. The network portion must be the same for all devices of the system concerned, the piece of equipment on each unit vary within the network. The netmasks of all machines participating in an IP network should thus be configured the same.

Regardless of allocated IP addresses are network masks or prefix lengths used in the presentation of IP networks in routing tables and filter definitions in both routing protocols as well as in packet filters. The above piece of equipment is hereby stated or omitted in all the binary digits with a zero.

Analogy: In a nationally valid phone number, consisting of area code and extension number if all digits are sequentially written, the information of where the code ends and the port number starts missing. Therefore, the two parts are separated by a special character (often "/") written separately or area code is enclosed in brackets. This kind of information is contained in the indication of an IP network in the network mask, or prefix length. The representation of an IP network is then similar to the indication of the bare area code.

Representation

Bits

A netmask is the same length as an IPv4 address, so 32 bits. All bits of the network portion are set to 1, all bits of the device part have the value 0, the network portion of an IPv4 address is given by its bitwise logical AND operation on the netmask. After the bitwise negation of the netmask of the piece of equipment is well separated.

Example

In such a network mask with 24 bits set to remain 8 bits and therefore 28 = 256 addresses for appliance parts. One speaks of a 24 -bit network. Because the smallest address (all bits in the device part are zero) describes the network itself and the largest address (all bits in the device are part of one) is reserved for the broadcast, they are not among the addresses that are distributed to devices. So there are 254 addresses for devices.

IPv4

The notation netmask as IPv4 addresses is usually not in the binary system, but the decimal system. Then, the IP address of the above example 192.168.1.129 and the subnet mask 255.255.255.0 or short / 24 Thus, the network part and the device part is 192.168.1 129 The IP network can be described as 192.168.1.0/24.

During the CIDR Notation / 24 indicates the number of set bits in the netmask, the netmask is decimal decomposed in dotted notation in four octets, which are represented by decimal numbers. The decimal number 255 has the same value as the binary number 11111111, which is equal to 8 bits set. This way, in Example 8 8 8 0 = 24 bits set. An overview of all IPv4 netmasks greater than / 8 is in different notations in the CIDR article.

Example 1: It will examine the IP address 192.168.1.188/27, in other notation 192.168.1.188/255.255.255.224. The network mask is a 27 -bit mask. First, the question should be clarified how many IP addresses belong to a 27 -bit network. Answer: An IPv4 address consists of 32 bits. 32 minus 27 is 5, the 27 -bit mask so lets 2 high 5 addresses at your disposal, ie 32 to a 27 -bit network thus includes 32 addresses. Now the question is to clarify how the network is, to which the address belongs. Answer: The smallest address from the predetermined amount is the net 's name. They can be found by starting from 188 starting examines the next smaller number that is divisible by 32. The result is 160 The power is to say 192.168.1.160/27. The group includes the 32 addresses from 192.168.1.160 to 192.168.1.191 including. The address 192.168.1.160 means the network itself, 192.168.1.191 is the broadcast address. Available for devices remain the 30 IP addresses from 192.168.1.161 to 192.168.1.190 including.

Example 2: 172.16.0.0/16 172.16.0.0/24 and differ in that the first network, the IP addresses 172.16.0.1 to 172.16.255.254 covers, while the second includes only the range 172.16.0.1 to 172.16.0.254.

IPv6

IPv6 uses a different netmask than IPv4. The main differences are summarized 5942 (IPv6 Subnet Model) in RFC. In the IPv6 prefix length for the number of bits is simple as in CIDR separately in the Network part by "/" written behind the IPv6 address 2001:0 db8 for example: 85a3: 08d3: 1319:8 a2e: 0370:7347 / 64 The prefix length in this case is / 64, the network 2001:0 db8: 85a3: 08d3: 0000:0000:0000:0000 / 64 and the piece of equipment or interface identifier is 1319:8 a2e: 0370:7347. This notation is also suitable for IPv4 by more and more.

A less intuitive example is 2001:0 db8: 85a3: 08d3: 1319:8 a2e: 0370:7347 / 57 the related network is 2001:0 db8: 85a3: 0880:0000:0000:0000:0000 / 57 and contains the address 2001:0 db8: 85a3: 2001:0 db8 0880:0000:0000:0000:0000 to: 85a3: 08ff: ffff: ffff: ffff: ffff some of which are intended for special functions. Dealing with little clear IPv6 networks facilitates the tool freely available sipcalc:

$ Sipcalc 2001:0 db8: 85a3: 08d3: 1319:8 a2e: 0370:7347 / 57 - [ ipv6: 2001:0 db8: 85a3: 08d3: 1319:8 a2e: 0370:7347 / 57 ] - 0 [ IPV6 INFO] Expanded Address - 2001:0 db8: 85a3: 08d3: 1319:8 a2e: 0370:7347 Compressed address - 2001: db8: 85a3: 8D3: 1319:8 a2e: 370:7347 Subnet prefix (masked ) - 2001: db8: 85a3: 880:0:0:0:0 / 57 Address ID (masked ) - 0:0:0:53:1319:8 a2e: 370:7347 / 57 Prefix address - ffff: ffff: ffff: FF80: 0:0:0:0 Prefix length - 57 Address type - Aggregate Global Unicast Addresses Network range - 2001:0 db8: 85a3: 0880:0000:0000:0000:0000 -       2001:0 db8: 85a3: 08ff: ffff: ffff: ffff: ffff Prefix lengths as network sizes

The netmask (IPv4 ) or prefix length (IPv6 ) can also be understood as a size specification of an IP network, with larger prefix lengths mean smaller networks, since not as many bits are available for equipment parts.

Examples

More Examples: All values ​​.

598348
de