次の方法で共有


Expressing an IP address range with a mask

Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1, Windows Server 2003 with SP2

Expressing an IP address range with a mask

In some cases, Routing and Remote Access allows you to enter a range of IP addresses as a starting and ending range. For example, when creating a DHCP scope, you enter the IP address range as 10.0.0.1 through 10.0.0.199. In this case, a suitable range for an arbitrary number of required IP addresses is specified.

In other cases, Routing and Remote Access requires you to enter a range of IP addresses as an IP address and mask. In these cases, a range for an arbitrary number of required IP addresses cannot be specified due to the mathematical relationship between the IP address and the mask. When expressing an IP address range in this way, you must choose a base IP address and a mask.

  • An IP address is a 32-bit number that is expressed as a series of 4 octets converted to base 10 and separated by the period character. This is commonly known as dotted decimal notation. The base IP address contains a series of bits that are fixed and a series of bits that are variable. The bits that are fixed must be a set of contiguous bits starting from the high order bit. The range of IP addresses formed from the base IP address is the set of addresses defined by all of the possible values of the variable bits.

  • The mask is a 32-bit number (also expressed in dotted decimal notation) that is used to explicitly define which bits in the base IP address are fixed and which bits are variable. In the mask, a 1 bit is used to indicate a bit in the IP address that is fixed. A fixed bit cannot be used to express the range. A 0 bit in the mask is used to indicate a bit in the IP address that is variable.

Because the bits that are fixed in the base IP address must be contiguous from the high order bit, a mask must consist of a series of contiguous 1 bits that represent the fixed portion of the address followed by a series of contiguous 0 bits that represent the variable portion of the address.

The following table shows examples of valid masks.

Subnet mask (binary) Subnet mask (decimal)

11111111 11111111 11110000 00000000

255.255.240.0

11111111 11111111 11111111 00000000

255.255.255.0

11111111 11111111 11111111 11100000

255.255.255.224

The following table shows examples of invalid masks.

Subnet mask (binary) Subnet mask (decimal)

11111111 11111111 10110000 00000000

255.255.176.0

11111111 11111111 11110000 11110000

255.255.240.240

11111111 11111111 11111111 00000111

255.255.255.7

The base IP address, the mask, and the range of addresses are related to each other by a mathematical operation called a bit-wise logical AND. In a bit-wise logical AND, the 32 bits of an IP address are lined up with the 32 bits of the mask. For each bit, a logical AND is performed. In a logical AND, the result is a 1 if both bits being compared are a 1 and a 0 otherwise.

Because the variable bits in the mask are always 0, the bit-wise logical AND of any IP address in the range (including the base IP address) and the mask always produces the same result: the base IP address.

The base IP address cannot have a 1 where there is a 0 in the mask. A bit-wise logical AND of a 1 with a 0 always produces a 0. Therefore, a base IP address with a 1 where there is a 0 in the mask will, when a bit-wise logical AND is used with the mask, not produce the base IP address. This is the reason for the error message: "The network mask entered is not valid. The destination address cannot be more specific than the network mask."

The base IP address that contains a 1 where there is a 0 is more specific than the mask. A base IP address can be less specific than the mask, but not more specific.

The following table shows an example of a valid address range.

  Binary Decimal

Base IP address

11000000 10101000 10011100 00000000

192.168.156.0

Mask

11111111 11111111 11111100 00000000

255.255.252.0

In this example, the first 22 bits are fixed and the last 10 bits are variable. Notice how the bit-wise logical AND of the base IP address and the mask produces the base IP address (192.168.156.0 AND 255.255.252.0 = 192.168.156.0).

The following table shows an example of a invalid address range.

  Binary Decimal

Base IP address

11000000 10101000 00111001 00000000

192.168.57.0

Mask

11111111 11111111 11110000 00000000

255.255.240.0

In this example, there are two bits in the base IP address set to 1 that are not included in the mask. Notice how the bit-wise logical AND of the base IP address and the mask does not produce the base IP address (192.168.57.0 AND 255.255.240.0 = 192.168.48.0).

Multicast scopes

The base IP address and mask that you choose for multicast scopes depends on two factors:

  1. The originating address space

    The originating address space is the original set of addresses from which a range is being defined. For example, when defining multicast scopes, the originating address space is from 239.0.0.0 through 239.254.255.255.

  2. The number of addresses needed

    The following table lists the mask needed based on a required number of addresses.

Number of addresses required Number of fixed bits Number of variable bits Mask

1-2

31

1

255.255.255.254

3-4

30

2

255.255.255.252

5-8

29

3

255.255.255.248

9-16

28

4

255.255.255.240

17-32

27

5

255.255.255.224

33-64

26

6

255.255.255.192

65-128

25

7

255.255.255.128

129-256

24

8

255.255.255.0

257-512

23

9

255.255.254.0

513-1,024

22

10

255.255.252.0

1,025-2,048

21

11

255.255.248.0

2,049-4,096

20

12

255.255.240.0

4,097-8,192

19

13

255.255.224.0

8,193-16,384

18

14

255.255.192.0

16,385-32,768

17

15

255.255.128.0

32,769-65,536

16

16

255.255.0.0

65,537-131,072

15

17

255.254.0.0

131,073-262,144

14

18

255.252.0.0

262,145-524,288

13

19

255.248.0.0

524,289-1,048,576

12

20

255.240.0.0

1,048,577-2,097,152

11

21

255.224.0.0

2,097,153-4,194,304

10

22

255.192.0.0

4,194,305-8,388,608

9

23

255.128.0.0

8,388,609-16,777,216

8

24

255.0.0.0

Based on the base IP address, the range is defined as follows:

  • The first IP address in the range is the base IP address.

  • The last IP address in the range is the address obtained by setting all the variable bits to a 1 and then expressing the result in dotted decimal notation.

The following table shows an example for a multicast scope.

  Decimal Binary

IP address

239.0.64.0

11101111 00000000 01000000 00000000

Mask

255.255.192.0

11111111 11111111 11000000 00000000

First IP address

239.0.64.0

11101111 00000000 01000000 00000000

Last IP address

239.0.128.255

11101111 00000000 01111111 11111111