ipcalc-for-cloud
Scannednpx machina-cli add skill jvhoof/ipcalc/ipcalc-for-cloud --openclawSupported Cloud Providers:
- Azure: VNets with subnets, optional hub-spoke peering
- AWS: VPCs with subnets distributed across AZs
- GCP: VPCs with subnets (hub-spoke supported)
- Oracle Cloud: VCNs with subnets
- AliCloud: VPCs with subnets
- On-Premises: Basic IP calculations
Output Formats by Provider:
- Azure: info, JSON, Terraform, Bicep, ARM, PowerShell, Azure CLI
- AWS: info, JSON, Terraform, CloudFormation, AWS CLI
- GCP: info, JSON, Terraform, gcloud
- Oracle: info, JSON, Terraform, OCI CLI
- AliCloud: info, JSON, Terraform, Aliyun CLI
- On-Premises: info, JSON
Uses Python for deterministic IP calculations matching the TypeScript CLI implementation. </objective>
<quick_start> Basic usage - calculate subnets for a single VNet/VPC:
Show network information:
/ipcalc-for-cloud "azure, 10.0.0.0/16, 4 subnets"
Generate Terraform for AWS:
/ipcalc-for-cloud "aws, 10.0.0.0/16, 3 subnets, output: terraform"
Custom subnet prefix (to avoid filling entire network):
/ipcalc-for-cloud "azure, 172.16.1.0/24, 4 subnets, prefix: /26"
Hub-spoke topology for Azure:
/ipcalc-for-cloud "azure, 10.0.0.0/16, 2 subnets, spokes: 10.1.0.0/16,10.2.0.0/16, spoke-subnets: 2,2, output: terraform"
The skill will:
- Calculate optimal CIDR splits based on provider constraints
- Distribute subnets across availability zones (AWS/GCP)
- Apply provider-specific reserved IP calculations
- Validate IP allocations
- Output in requested format </quick_start>
Accept user input specifying:
- Cloud provider: azure, aws, gcp, oracle, alicloud, onpremises
- Base CIDR: Network CIDR block (e.g., "10.0.0.0/16")
- Number of subnets: How many subnets to create (1-256)
- Output format: info (default), json, terraform, bicep, arm, powershell, cloudformation, cli, gcloud, oci, aliyun
- Optional - Custom prefix: Desired subnet prefix (e.g., /26) to override auto-calculation
- Optional - Hub-spoke: Spoke network CIDRs and subnet counts for hub-spoke topology
Extract:
- Cloud provider selection
- Base IP range (CIDR notation)
- Number of subnets for primary network
- Output format
- Custom subnet prefix (if specified)
- Spoke network specifications (if hub-spoke topology)
Step 2: Run IP Calculations
Execute the IP calculation script with cloud provider configuration:
python ~/.claude/skills/ipcalc-for-cloud/scripts/ipcalc.py \
--provider azure \
--cidr "10.0.0.0/16" \
--subnets 4 \
--output terraform
With custom subnet prefix:
python ~/.claude/skills/ipcalc-for-cloud/scripts/ipcalc.py \
--provider azure \
--cidr "172.16.1.0/24" \
--subnets 4 \
--prefix 26 \
--output info
With hub-spoke topology:
python ~/.claude/skills/ipcalc-for-cloud/scripts/ipcalc.py \
--provider azure \
--cidr "10.0.0.0/16" \
--subnets 2 \
--spoke-cidrs "10.1.0.0/16,10.2.0.0/16,10.3.0.0/16" \
--spoke-subnets "2,2,2" \
--output terraform
The script will:
- Validate base CIDR against provider constraints
- Calculate optimal subnet prefix OR use custom prefix
- Check capacity (can the network accommodate requested subnets?)
- Generate subnet CIDR assignments
- Distribute subnets across availability zones (AWS, GCP)
- Calculate provider-specific reserved IPs (Azure: 5, AWS: 5, GCP: 4, Oracle: 3)
- Calculate usable IP ranges
- Detect any overlaps or invalid ranges
- For hub-spoke: Calculate spoke networks and configure peering
- Output structured data for template rendering
Step 3: Output Results
Based on requested output format and provider:
Info format (default):
- Human-readable formatted table
- Network details (CIDR, total IPs, address range)
- Subnet details with availability zones
- Reserved and usable IP information
- Provider-specific formatting
JSON format:
- Structured JSON data
- Complete network and subnet information
- Availability zone assignments
- Reserved IP lists
- Machine-readable for integration
Terraform format: Generate HCL code with:
- Provider configuration (azurerm, aws, google, etc.)
- Variables for customization
- Network resource (VNet/VPC)
- Subnet resources with AZ distribution
- Outputs for resource IDs
- Hub-spoke peering resources (if applicable)
- Comments with IP allocation table
Other IaC formats:
- Bicep: Azure Bicep template with inline subnets
- ARM: Azure Resource Manager JSON template
- PowerShell: Azure PowerShell script with cmdlets
- CloudFormation: AWS YAML template with intrinsic functions
- CLI Scripts: Bash scripts with az/aws/gcloud commands
Step 4: Validate Output
Run validation checks:
- IP range validation (no overlaps, proper nesting)
- Provider constraint validation (prefix limits)
- Capacity validation (requested subnets fit in network)
- For Terraform: syntax validation (if terraform CLI available)
- For hub-spoke: peering configuration correctness </workflow>
-
IP Range Validation:
- Verify all subnets fit within parent network
- Confirm no overlapping ranges
- Validate CIDR notation
- Check provider constraints (min/max prefix)
-
Provider Constraint Validation:
- Azure: /8 to /29
- AWS: /16 to /28
- GCP: /8 to /29
- Oracle: /16 to /30
- AliCloud: /8 to /29
-
Capacity Validation:
- Requested subnets fit in network
- Custom prefix (if specified) allows requested subnet count
- No address space exhaustion
-
Manual Review Checklist:
- Subnets properly sized for intended use
- Availability zone distribution is appropriate
- Reserved IPs calculated correctly for provider
- Usable IP counts are accurate
- Hub-spoke peering configured correctly (if applicable)
Additional validation for IaC output:
-
Syntax Validation (if CLI tools available):
# Terraform terraform init && terraform validate # Azure Bicep az bicep build --file output.bicep # AWS CloudFormation aws cloudformation validate-template --template-body file://output.yaml -
IaC Checklist:
- Provider configuration present and correct version
- Resource naming follows conventions
- Variables defined for customization
- Output variables defined for resource IDs
- Hub-spoke peering resources complete (if applicable)
- IP allocation documented in comments </validation>
<advanced_features> Custom Subnet Prefix: Specify exact subnet size instead of auto-calculation:
/ipcalc-for-cloud "azure, 172.16.1.0/24, 4 subnets, prefix: /26"
Use case: Avoid filling entire network, leave room for future expansion
Hub-Spoke Topology (Azure, GCP): Create centralized hub network with multiple spoke networks:
/ipcalc-for-cloud "azure, 10.0.0.0/16, 2 subnets, spokes: 10.1.0.0/16,10.2.0.0/16,10.3.0.0/16, spoke-subnets: 2,3,2, output: terraform"
Generates bidirectional peering between hub and each spoke
Multi-Provider Support: Same IP calculations work across all cloud providers with provider-specific adjustments:
- Reserved IP counts
- CIDR prefix constraints
- Availability zone naming
- Output format availability
Availability Zone Distribution (AWS, GCP): Automatic round-robin distribution of subnets across AZs for high availability
Legacy Compatibility: Old command-line options still supported for backward compatibility:
python ipcalc.py --base-cidr "10.0.0.0/16" --vnets 3 --subnets-per-vnet 4
(Creates multiple VNets instead of single VNet with subnets) </advanced_features>
<scripts_reference>
scripts/ipcalc.py
Main IP calculator script supporting multiple cloud providers and output formats.
Key Functions:
calculate_subnets(cidr, num_subnets, provider, desired_prefix)- Calculate subnet allocationsgenerate_hub_spoke_topology(hub_cidr, hub_subnets, spoke_cidrs, spoke_subnets, provider)- Hub-spoke networkscalculate_network_info(network, provider_config)- Detailed network informationformat_network_info(cidr, subnets, provider)- Human-readable output
Usage:
python scripts/ipcalc.py --provider PROVIDER --cidr CIDR --subnets N [OPTIONS]
Options:
--provider: Cloud provider (azure, aws, gcp, oracle, alicloud, onpremises)--cidr: Network CIDR block--subnets: Number of subnets (1-256)--prefix: Optional custom subnet prefix--output: Output format (info, json, terraform, bicep, arm, powershell, cloudformation, cli, gcloud, oci, aliyun)--file: Write output to file--spoke-cidrs: Comma-separated spoke VNet/VPC CIDRs--spoke-subnets: Comma-separated subnet counts per spoke
Output Format (JSON):
{
"vnetCidr": "10.0.0.0/16",
"provider": "azure",
"subnets": [
{
"name": "subnet1",
"cidr": "10.0.0.0/18",
"network": "10.0.0.0",
"mask": "255.255.192.0",
"total_ips": 16384,
"usable_ips": 16379,
"usable_range": "10.0.0.3 - 10.0.63.253",
"availabilityZone": "1",
"reserved": ["10.0.0.0", "10.0.0.1", "10.0.0.2", "10.0.63.254", "10.0.63.255"]
}
],
"peeringEnabled": false
}
scripts/cloud_provider_config.py
Cloud provider configuration module defining provider-specific settings.
Configurations:
- Reserved IP counts (Azure: 5, AWS: 5, GCP: 4, Oracle: 3, etc.)
- CIDR prefix limits (min/max)
- Availability zone lists
- Supported output formats
Functions:
get_cloud_provider_config(provider)- Get provider configurationvalidate_output_format(provider, output_format)- Validate output format supportget_availability_zone(provider, index)- Get AZ for subnet index (round-robin)
scripts/ipcalc_legacy.py
Legacy version supporting old multi-VNet split behavior. Use for backward compatibility:
python scripts/ipcalc_legacy.py --base-cidr "10.0.0.0/16" --vnets 3 --subnets-per-vnet 4
Creates 3 separate VNets instead of 1 VNet with subnets. </scripts_reference>
<templates_reference>
Template Architecture
Templates are organized by provider and format:
templates/
├── azure/
│ ├── terraform.template.tf
│ ├── bicep.template.bicep
│ ├── arm.template.json
│ ├── powershell.template.ps1
│ └── cli.template.sh
├── aws/
│ ├── terraform.template.tf
│ ├── cloudformation.template.yaml
│ └── cli.template.sh
└── ...
Template Placeholders: Common across all templates:
{{vnetCidr}}/{{vpcCidr}}- Network CIDR{{subnetVariables}}- Subnet variable declarations{{subnetResources}}- Subnet resource definitions{{subnetOutputs}}- Output definitions{{spokeVnetResources}}/{{spokeVpcResources}}- Spoke network resources{{vnetPeeringResources}}/{{vpcPeeringResources}}- Peering configurations
Template Processor:
The template processor module (template_processor.py) generates placeholder content:
- Variable/parameter declarations
- Resource definitions with proper syntax
- Hub-spoke peering logic
- Provider-specific formatting
Templates use simple string replacement for placeholders, maintaining exact output compatibility with TypeScript CLI. </templates_reference>
<anti_patterns>
<pitfall name="filling_entire_network">
❌ Auto-calculating subnet size fills entire network, no room for growth
✅ Use --prefix option to specify smaller subnets, leave address space for future
</pitfall>
<success_criteria> The skill successfully completes when:
For all providers and outputs:
- IP calculations are mathematically correct and deterministic
- Provider constraints are enforced (CIDR prefix limits)
- Reserved IPs calculated correctly for provider
- Subnets fit within parent network
- No CIDR blocks overlap
- Multiple invocations with same input produce identical output
- Output format matches user request
For AWS and GCP:
- Subnets distributed across availability zones using round-robin
- AZ names match provider conventions
For hub-spoke topologies:
- Hub network calculated correctly
- All spoke networks calculated correctly
- Bidirectional peering configured for each spoke
- No overlapping CIDRs between hub and spokes or between spokes
For IaC template outputs:
- Generated code passes syntax validation
- Provider configuration is present and correct
- Resource naming follows cloud provider conventions
- Variables defined for customization
- Outputs defined for resource IDs
- Documentation included (IP allocation table in comments)
- Hub-spoke peering resources complete (if applicable)
Compatibility:
- Output matches TypeScript CLI output for same inputs
- Legacy compatibility maintained via
ipcalc_legacy.py</success_criteria>
Source
git clone https://github.com/jvhoof/ipcalc/blob/main/skills/ipcalc-for-cloud/SKILL.mdView on GitHub Overview
ipcalc-for-cloud computes IP ranges, CIDR blocks, and subnet allocations for cloud networks across Azure, AWS, GCP, Oracle Cloud, and AliCloud. It supports single VNet/VPC or hub-spoke topologies with automatic AZ distribution and provider-specific reserved IP handling, producing info tables, JSON, or IaC templates (Terraform, Bicep, ARM, PowerShell, CloudFormation).
How This Skill Works
The tool parses provider, base CIDR, and subnet counts, then performs CIDR subnetting, validates ranges, and detects overlaps. It distributes subnets across availability zones as supported, applies provider-specific reserved IP calculations, and outputs the results in the requested format (info, JSON, or IaC templates). It uses Python for deterministic IP calculations matching the TypeScript CLI.
When to Use It
- Planning a new cloud VNet/VPC with multiple subnets
- Distributing subnets across availability zones (AWS/GCP)
- Validating IP ranges and detecting overlaps before deployment
- Exporting IaC templates (Terraform, Bicep, ARM, CloudFormation) for deployment
- Designing hub-spoke topologies with spoke CIDRs and subnet counts
Quick Start
- Step 1: Define provider, base CIDR, and number of subnets
- Step 2: Run the calculation (e.g., ipcalc-for-cloud --provider aws --cidr '10.0.0.0/16' --subnets 4 --output terraform)
- Step 3: Use the generated output (Terraform/Bicep/ARM/JSON) in deployment
Best Practices
- Start with a large enough base CIDR to accommodate future growth
- Account for provider-specific reserved IPs and subnet sizing rules
- Prefer deterministic, non-overlapping CIDRs and document mappings
- Test outputs in info or JSON before generating IaC templates
- Validate hub-spoke or multi-AZ layouts against your security and routing needs
Example Use Cases
- AWS: VPC 10.0.0.0/16 split into 4 subnets across 3 AZs with CloudFormation output
- Azure: hub-spoke 10.0.0.0/16 with spoke subnets 10.1.0.0/16 and 10.2.0.0/16
- GCP: VPC with regional subnets across multiple regions
- Oracle Cloud: VCN with multiple subnets and provider-specific reserved IPs
- AliCloud: VPC with subnets sized for workload and CIDR hygiene