diff --git a/app/Services/Subnet.php b/app/Services/Subnet.php index 36322f3..ff54bbe 100644 --- a/app/Services/Subnet.php +++ b/app/Services/Subnet.php @@ -40,7 +40,7 @@ class Subnet throw new Exception("CIDR must be between 0 and 32."); } - $hosts = (1 << (32 - $cidr)) - 2; // Excludes network and broadcast + $hosts = ($cidr === 32) ? 1 : (1 << (32 - $cidr)) - 2; // Special case for /32 $ipLong = ip2long($ip); $mask = -1 << (32 - $cidr); $network = $ipLong & $mask;