"Isn't a valid IP address or CIDR block" error while saving the IP address range in Access Controls
Platform Notice: Cloud - This article applies to Atlassian products on the cloud platform.
Summary
When trying to add an individual IP or IP range to the IP Allowlisting (Workspace settings > Access Controls) of a workspace, the error message "Isn't a valid IP address or CIDR block" is returned.
Cause
The IP address you are trying to add is not a valid IPv4 or IPv6, or the IP range is not a valid CIDR block.
For individual IPs, Bitbucket supports IPv4 and IPv6. For IP range, we support CIDR notation.
Saving an incorrect/invalid IP address or IP range in Access Controls feature return “<IP/IP Range> Isn't a valid IP address or CIDR block” error in the UI.
Solution
- For individual IP addresses
Check if the IP is compliant with the IPv4 format or IPv6 format.
- For IP ranges
Verify if you are using the CIDR notation to define the IP range.
CIDR network address is a way to specify the range of the IP addresses. In the case of A.B.C.D/18, A.B.C.D is the network address itself and the "18" says that the first 18 bits are the network part of the address, leaving the last 14 bits for specific host addresses. Also, in the above example, since the last 14 bits are used for the host address, they should always have all the bit values as 0 while specifying the CIDR address.
Examples of CIDR ranges :
112.78.170.106/29 - As per the CIDR notation, the first 29 bits will be used for the network part of the address and the last three bits will be used for the host address and those three bits should be zero. However, in the given CIDR address last three bits are not zero. If we consider only the last IP part (106), it has an equivalent binary value as 01101010, where the last three binary values are not zero, hence CIDR address is invalid. To make it valid, it should have the following binaries - 01101000 which results in 104. Thus, the valid alternative CIDR for this example would be 112.78.170.104/29
36.91.111.183/30 - As per the CIDR notation, the first 30 bits will be used for the network part of the address and the last two bits will be used for the host address and those two bits should be zero. However, in the given CIDR address last two bits are not zero. If we consider only the last IP part (183), it has an equivalent binary value as 10110111, where the last two binary values are not zero hence CIDR address is invalid. To make it correct, we can have the following binaries - 10110100 which results in 180. Hence, the valid alternative CIDR for this example would be 36.91.111.180/30