Calculate subnet masks and addresses for given CIDR notation.

CIDR notation consists of an IP address and a prefix length separated by a forward slash ("/"). The IP address represents the network, and the prefix length indicates the number of bits used for the network portion of the address.

Example CIDR Notation:

Here, "" is the network address, and "/24" means that the first 24 bits are reserved for the network portion.

  1. Convert the CIDR prefix length to binary:
    • In our example, the prefix length is 24. Convert it to binary:
      • 24 in binary is 11111111 11111111 11111111 00000000.
  2. Determine the subnet mask:
    • The subnet mask is created by setting the first 24 bits to "1" and the remaining bits to "0".
    • Using our binary representation from step 1:
      • Subnet Mask: 11111111 11111111 11111111 00000000
      • Convert this back to decimal:
  3. Identify the number of subnets and hosts:
    • The remaining bits in the address (32 - prefix length) indicate the number of bits available for host addresses.
    • In our example: 32 - 24 = 8 bits available for hosts.
    • This allows for 2^8 (256) possible host addresses in each subnet.
  4. Calculate subnet addresses:
    • The subnet addresses can be calculated by incrementing the last octet of the network address by the number of hosts.
    • In our example:
      • Subnet 1:
      • Subnet 2: * 256 =
      • Subnet 3: * 256 =
      • and so on...
  5. Determine the range of usable IP addresses in each subnet:
    • The first address in the subnet is the network address, and the last address is reserved for broadcast. So, usable IP addresses are between the first and last addresses.
    • In our example, for the first subnet (
      • Network address:
      • Usable IP range: to
      • Broadcast address: