Skip to main content
By default, Nebius AI Cloud networks and subnets provide private IP addresses from specific CIDR blocks. These blocks depend on the network’s or subnet’s region. If you need private addresses outside these blocks, add the required CIDR block to the network’s pool. Next, create a subnet with that CIDR block in the network. As a result, you can allocate random or specific addresses from this block in the required network or subnet.

Prerequisites

  1. Make sure you are in a group that has at least the editor role within your tenant; for example, the default editors group. You can check this in the Administration → IAM section of the web console.
  2. Install and initialize the Nebius AI Cloud CLI.
  3. Install jq to extract IDs and tokens from the JSON data returned by the Nebius AI Cloud CLI:
    sudo apt-get install jq
    

How to allocate addresses

  1. Determine what CIDR block you need and save it to an environment variable:
    export CUSTOM_SUBNET_CIDR=<CIDR_block>
    
    For example, you can specify the 172.16.0.0/24 CIDR block.
  2. Get the ID of the required network and save it to an environment variable:
    export NETWORK_ID=$(nebius vpc network get-by-name \
      --name <network_name> \
      --format json | jq -r ".metadata.id")
    
  3. Get the ID of this network’s private pool and save it to an environment variable:
    export PRIVATE_POOL_ID=$(nebius vpc network get \
      --id $NETWORK_ID \
      --format json | jq -r ".spec.ipv4_private_pools.pools[0].id")
    
    As this command contains pools[0], it saves the ID of the private pool that goes first in the network specification. If you need a different pool, specify its index in pools[<index>]. To check the order of pools, run nebius vpc network list.
  4. Add the CUSTOM_SUBNET_CIDR block to the private pool with PRIVATE_POOL_ID:
    echo $(nebius vpc pool get --id $PRIVATE_POOL_ID --format json | \
      jq '.spec.cidrs += [{"cidr":$ENV.CUSTOM_SUBNET_CIDR}] |
      {metadata: .metadata, spec: .spec}') | \
      nebius vpc pool update -
    
  5. Create a new subnet with this private pool and save the subnet ID to an environment variable:
    export SUBNET_ID=$(nebius vpc subnet create \
      --name private_subnet \
      --network-id $NETWORK_ID \
      --ipv4-private-pools-pools "[{\"cidrs\":[{\"cidr\":\"$CUSTOM_SUBNET_CIDR\"}]}]" \
      --format json | jq -r ".metadata.id")
    
  6. Create an allocation within this subnet and save its ID to an environment variable:
    export ALLOCATION_ID=$(nebius vpc allocation create \
      --name private_allocation \
      --ipv4-private-subnet-id $SUBNET_ID \
      --ipv4-private-cidr <IP_address> \
      --format json | jq -r ".metadata.id")
    
    The --ipv4-private-cidr parameter contains the IP address for the allocation:
    • If you use this parameter, make sure that the specified IP address is in the CIDR block of the private pool.
    • If you run the command without using the --ipv4-private-cidr parameter, it creates an allocation with a random IP address within the specified CIDR block.
Now, you can use the configured allocation in the resource creation commands. For example, if you want to create a VM, specify the allocation ID in the following way:
nebius compute instance create - <<EOF
{
  "metadata": { ... },
  "spec": {
    ...
    "network_interfaces": [
      {
        "name": "network-interface-0",
        "subnet_id": "$SUBNET_ID",
        "ip_address": {
          "allocation_id": "$ALLOCATION_ID"
        },
        "public_ip_address": {}
      }
    ]
  }
}
EOF
If you later delete this VM, you can reuse the allocation for another VM.