Technology Encyclopedia Home >How to convert CIDR notation to subnet mask?

How to convert CIDR notation to subnet mask?

Converting CIDR (Classless Inter-Domain Routing) notation to a subnet mask involves understanding the relationship between the number of bits used for the network portion of an IP address and the corresponding subnet mask.

In CIDR notation, an IP address is followed by a slash and a number that indicates how many bits are used for the network portion. For example, 192.168.1.0/24 indicates that the first 24 bits of the IP address are used for the network portion.

To convert this to a subnet mask, you take the number of bits and create a binary number with that many 1s followed by the remaining bits as 0s. For /24, this would be 11111111.11111111.11111111.00000000.

Converting this binary number to decimal gives you the subnet mask 255.255.255.0.

Example:

  • CIDR notation: 10.0.0.0/16
  • Binary subnet mask: 11111111.00000000.00000000.00000000
  • Decimal subnet mask: 255.0.0.0

For more advanced networking needs in the cloud, consider using services like Tencent Cloud's Virtual Private Cloud (VPC), which allows you to create and manage your own virtual networks with customizable subnet masks and CIDR blocks.