> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nebius.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Private and public IP addresses of Compute virtual machines

Virtual machines in Compute can be reached at their private and public IP addresses.

## Private IP addresses

Each VM is created with a network interface that has a private IPv4 address. VMs can communicate with each other without internet access by using their private addresses.

Private address ranges are randomly allocated from subnets with the `10.0.0.0/8` and `192.168.0.0/16` IPv4 CIDR blocks.

### How to get a VM's private IP address

<Tabs group="interface">
  <Tab title="Web console">
    1. In the sidebar, go to <Icon icon="https://mintcdn.com/nebius-ai-cloud/1Ha0sWR6e1mnIaHS/_assets/sidebar/compute.svg?fit=max&auto=format&n=1Ha0sWR6e1mnIaHS&q=85&s=b91340217b08a1456d88ae0347f281d1" width="16" height="16" data-path="_assets/sidebar/compute.svg" /> **Compute** → **Virtual machines**.
    2. Open the page of the required VM.
    3. Copy the **Private IPv4** value from the **Network** block.
  </Tab>

  <Tab title="CLI">
    ```bash theme={null}
    export PRIVATE_IP_ADDRESS=$(nebius compute instance get-by-name \
      --name <VM_name> \
      --format json \
      | jq -r '.status.network_interfaces[0].ip_address.address | split("/")[0]')
    echo $PRIVATE_IP_ADDRESS
    ```
  </Tab>
</Tabs>

### How to assign a secondary private IP address to a VM

You can use secondary private IP addresses as a backup option in case of incidents. For example, a backup node can take a secondary address of the main node when the main one fails. As a result, routing to this address can be preserved.

<Tabs>
  <Tab title="Web console">
    To assign a secondary private address to a VM:

    1. In the sidebar, go to <Icon icon="https://mintcdn.com/nebius-ai-cloud/1Ha0sWR6e1mnIaHS/_assets/sidebar/compute.svg?fit=max&auto=format&n=1Ha0sWR6e1mnIaHS&q=85&s=b91340217b08a1456d88ae0347f281d1" width="16" height="16" data-path="_assets/sidebar/compute.svg" /> **Compute** → **Virtual machines**.
    2. Open the page of the required VM.
    3. Click **Attach resource** → **Secondary private IP**.
    4. In the window that opens, select whether you want to reuse an existing IP address as a secondary one or create a new address.
    5. For an existing IP address, select an allocation and then click **Assign address**.
    6. For a new address, specify the allocation name and address. After that, click **Create and assign address**.
  </Tab>

  <Tab title="CLI">
    To assign a secondary private address to a VM, first create a private allocation with the required address. After that, add this allocation to the VM specification.

    1. Get the [subnet ID](/vpc/networking/resources#how-to-get-a-subnet) for the allocation.

    2. Check what private CIDR blocks this subnet includes:

       ```bash theme={null}
       nebius vpc subnet get --id <subnet_ID>
       ```

       The available CIDR blocks are specified in the `status.ipv4_private_cidrs` parameter in the output.

    3. Create an allocation that reserves a private address. Use the address that belongs to one of the received private CIDR blocks.

       ```bash theme={null}
       nebius vpc allocation create \
         --name private_allocation \
         --ipv4-private-subnet-id <subnet_ID> \
         --ipv4-private-cidr <IP_address>
       ```

       Copy the allocation ID from the output.

    4. Assign the allocation to the required VM:

       ```bash theme={null}
       nebius compute instance update \
         --id <VM_ID> \
         --network-interfaces "[{\"aliases\": [{\"allocation_id\": \"<allocation_ID>\"}] }]"
       ```

    For more information, see [Allocating custom private addresses to resources](/vpc/addressing/custom-private-addresses).
  </Tab>
</Tabs>

## Public IP addresses

When creating a VM, you can enable public IPv4 addressing for it. A VM's public address is mapped to its private address by using one-to-one NAT.

All IP addresses assigned to a VM are [allocations](/vpc/overview#allocation). When you create a VM and automatically assign a static or dynamic public address, Compute creates an allocation for it and assigns this address to this VM. After that, Compute manages the lifecycle of this allocation. In particular, Compute deletes the allocation when the VM is deleted.

Public IP addresses are allocated from the public IPv4 ranges available for a given project. The available range depends on the [region](/overview/regions) where you create a VM. For instructions on how to get these ranges, see [Getting public IPv4 ranges for projects](/vpc/addressing/public-address-ranges).

If you assign an already existing allocation when you create a VM, Virtual Networks manages the lifecycle of this allocation. In this case, the allocation is preserved even if you delete the VM.

If you need to secure your VM and make it isolated, you can create a VM without a public IP address. If you need to connect to this VM from the internet, you can [set up a WireGuard jump server](/compute/virtual-machines/wireguard). It has an IP address in the internet and an IP address in the VM's network. As a result, you can access the VM via the jump server from the internet. This approach enhances security and still provides access to the VM.

### How to enable a public IP address for a VM

To enable a public address, either [create a VM](#how-to-create-a-vm-with-a-public-ip-address) with it or [assign a public address to an existing VM](#how-to-enable-a-public-ip-address-for-an-existing-vm).

A VM must be in the same [region](/overview/regions) as the VM's subnet. An allocation assigned to a VM must belong to the VM's subnet. For more information, see [Virtual Networks documentation](/vpc/overview).

#### How to create a VM with a public IP address

<Tabs group="interface">
  <Tab title="Web console">
    On the VM creation page (<Icon icon="https://mintcdn.com/nebius-ai-cloud/1Ha0sWR6e1mnIaHS/_assets/sidebar/compute.svg?fit=max&auto=format&n=1Ha0sWR6e1mnIaHS&q=85&s=b91340217b08a1456d88ae0347f281d1" width="16" height="16" data-path="_assets/sidebar/compute.svg" /> **Compute** → **Virtual machines** → **Create virtual machine** → **Network** → **Public IP address**), select one of the following options:

    * **Auto assign dynamic IP** (default): A dynamic public IP address is randomly allocated from the [public IPv4 ranges available for the project](/vpc/addressing/public-address-ranges).

      Dynamic public IP addresses are not persistent. If a VM with a dynamic address has the `Stopped` status for more than one hour, the address automatically returns to the IPv4 public range of Nebius AI Cloud. After that, Compute may allocate this address to a different VM.

      If you want to preserve the address, assign a static address or an [allocation](/vpc/overview#allocation) to the VM.

    * **Auto assign static IP**: A static public IP address is randomly allocated from the public IPv4 ranges available for the project.

      If you stop a VM that has a static IP address, the address will not return to the range. However, if you delete this VM, the address will return.

    * **Select from already allocated**: A preliminarily created allocation is assigned to a VM.

      If you use an allocation, its address will not return to the IPv4 range even if you delete the VM.

    If you want to create a VM with a private address only, select the **No public IP** option.
  </Tab>

  <Tab title="CLI">
    You can [create a VM](./manage) with a public IP address. This can be either a dynamic address, a static address or an [allocation](../../vpc/overview#allocation):

    * A dynamic public IP address is randomly allocated from the [IPv4 public range](#get-public-ip-range) of Nebius AI Cloud and is not persistent. If a VM with a dynamic address has the `Stopped` status for more than one hour, the address is automatically returned to the IPv4 public range. After that, Compute may allocate this address to a different VM.
    * A static public IP address is also randomly allocated from the IPv4 public range of Nebius AI Cloud. If you stop a VM that has a static IP address, the address will not return to the range. However, if you delete this VM, the address will return.
    * An allocation allows you to use a reserved static public address for the VM. This address will not return to the IPv4 range even if you delete the VM.

    To create a VM with a **dynamic public IP address**:

    1. Get the [subnet ID](../../vpc/networking/resources#how-to-get-a-subnet-id) for the VM.
    2. Run the following command and specify the subnet ID in it:

       ```bash theme={null}
       nebius compute instance create \
         ... \
         --network-interfaces "[{\"name\": \"eth0\", \"ip_address\": {}, \"public_ip_address\": {}, \"subnet_id\": \"<subnet_ID>\"}]"
       ```

    To create a VM with a **static public IP address**:

    1. Get the [subnet ID](../../vpc/networking/resources#how-to-get-a-subnet-id) for the VM.
    2. Run the following command and specify the subnet ID in it:

       ```bash theme={null}
       nebius compute instance create \
         ... \
         --network-interfaces "[{\"name\": \"eth0\", \"ip_address\": {}, \"public_ip_address\": {\"static\": true}, \"subnet_id\": \"<subnet_ID>\"}]"
       ```

    To create a VM with an **already allocated public IP address**:

    1. Get the [subnet ID](../../vpc/networking/resources#how-to-get-a-subnet-id) for the VM.

    2. Create an allocation that reserves a static public address:

       ```bash theme={null}
       nebius vpc allocation create \
         --ipv4-public-subnet-id <subnet_ID> \
         --name <allocation_name>
       ```

    3. Create the VM. Specify the subnet ID and the allocation ID in the command:

       ```bash theme={null}
       nebius compute instance create \
         ... \
         --network-interfaces "[{\"name\": \"eth0\", \"ip_address\": {}, \"public_ip_address\": {\"allocation_id\": \"<allocation_ID>\"}, \"subnet_id\": \"<subnet_ID>\"}]"
       ```

    If you want to create a VM with a private address only, omit the `public_ip_address` parameter in the `nebius compute instance create` command.
  </Tab>
</Tabs>

<Note>
  If an allocation with a public address has not been assigned to any resource for 30 days, Nebius AI Cloud can delete this allocation and release its address. If you want to preserve the address, assign its allocation to a Nebius AI Cloud resource.
</Note>

#### How to enable a public IP address for an existing VM

You can only assign one public IP address to a VM. If the VM already has a public address, you cannot assign one more.

<Tabs>
  <Tab title="Web console">
    1. In the [web console](https://console.nebius.com), go to <Icon icon="https://mintcdn.com/nebius-ai-cloud/1Ha0sWR6e1mnIaHS/_assets/sidebar/compute.svg?fit=max&auto=format&n=1Ha0sWR6e1mnIaHS&q=85&s=b91340217b08a1456d88ae0347f281d1" width="16" height="16" data-path="_assets/sidebar/compute.svg" /> **Compute** → **Virtual machines**.
    2. Open the page of the required VM.
    3. Click **Attach resource** → **Public IP address**.
    4. In the window that opens, select whether you want to assign an existing IP address or create a new one.
    5. For an existing IP address, select the required one and then click **Assign address**.
    6. For a new address, specify the address type: dynamic or static. After that, click **Create and assign address**.

    After you enable an IP address for a VM, you can change the type of this address: make it static or dynamic. To do so, go to the VM page, open the **Network interface** tab and then click <Icon icon="https://mintcdn.com/nebius-ai-cloud/1Ha0sWR6e1mnIaHS/_assets/button-vellipsis.svg?fit=max&auto=format&n=1Ha0sWR6e1mnIaHS&q=85&s=e80b8e57c43bfd117679262e6a1334ad" width="12" height="24" data-path="_assets/button-vellipsis.svg" /> → **Edit type** in the line of the required address.
  </Tab>

  <Tab title="CLI">
    To enable a **dynamic public IP address** for a VM, run the following command:

    ```bash theme={null}
    nebius compute instance update \
      --id <VM_ID> \
      --network-interfaces "[{\"public_ip_address\": {} }]"
    ```

    To enable a **static public IP address** for a VM, run the following command:

    ```bash theme={null}
    nebius compute instance update \
      --id <VM_ID> \
      --network-interfaces "[{\"public_ip_address\": {\"static\": true}}]"
    ```

    To assign an **already allocated public IP address** to a VM:

    1. Get the [subnet ID](../../vpc/networking/resources.md#subnet) for the VM.

    2. Create an allocation that reserves a static public address:

       ```bash theme={null}
       nebius vpc allocation create \
         --ipv4-public-subnet-id <subnet_ID> \
         --name <allocation_name>
       ```

    3. Assign this allocation to the VM:

       ```bash theme={null}
       nebius compute instance update \
         --id <VM_ID> \
         --network-interfaces "[{\"public_ip_address\": {\"allocation_id\": \"<allocation_ID>\"}}]"
       ```
  </Tab>
</Tabs>

### How to get a VM's public IP address

<Tabs group="interface">
  <Tab title="Web console">
    1. In the sidebar, go to <Icon icon="https://mintcdn.com/nebius-ai-cloud/1Ha0sWR6e1mnIaHS/_assets/sidebar/compute.svg?fit=max&auto=format&n=1Ha0sWR6e1mnIaHS&q=85&s=b91340217b08a1456d88ae0347f281d1" width="16" height="16" data-path="_assets/sidebar/compute.svg" /> **Compute** → **Virtual machines**.
    2. Open the page of the required VM.
    3. Copy the **Public IPv4** value from the **Network** block.
  </Tab>

  <Tab title="CLI">
    ```bash theme={null}
    export PUBLIC_IP_ADDRESS=$(nebius compute instance get-by-name \
      --name <VM_name> \
      --format json \
      | jq -r '.status.network_interfaces[0].public_ip_address.address | split("/")[0]')
    echo $PUBLIC_IP_ADDRESS
    ```
  </Tab>
</Tabs>

### How to migrate a public static IP address from one VM to another

To reassign a public static IP address from one VM to another, detach this address from the source VM and attach it to the target VM.

Before you begin, make sure that you have a VM with a public static IP address (the source VM) and a VM without a public address (the target VM). For information about creating VMs, see [How to create a virtual machine in Nebius AI Cloud](./manage).

To migrate the address, do the following:

<Tabs>
  <Tab title="CLI">
    1. To get IDs of the source and target VMs, list all VMs:

       ```bash theme={null}
       nebius compute instance list
       ```

    2. Store the VMs' IDs in environment variables:

       ```bash theme={null}
       SOURCE_VM="<source_VM_ID>"
       TARGET_VM="<target_VM_ID>"
       ```

    3. Extract the allocation ID of the public static IP address currently attached to the source VM. This value is required to reassign the IP address to another VM.

       ```bash theme={null}
       ALLOC_ID=$(nebius compute instance get \
         --id "$SOURCE_VM" \
         --format json | jq -r '.status.network_interfaces[] | select(.name=="eth0")
         | .public_ip_address.allocation_id')
       ```

    4. Pin the allocation in the source VM specification. This prevents the allocation from being deleted when you detach it in the next step.

       ```bash theme={null}
       nebius compute instance update --patch \
         --id "$SOURCE_VM" \
         "$(jq -n --arg alloc "$ALLOC_ID" '{"spec":{"network_interfaces":[{"name":"eth0","public_ip_address":{"static":true,"allocation_id":$alloc}}]}}')"
       ```

    5. Remove the public IP address from the source VM. This makes the allocation available for reuse.

       ```bash theme={null}
       nebius compute instance update --patch \
         --id "$SOURCE_VM" \
         '{"spec":{"network_interfaces":
         [{"name":"eth0","public_ip_address":null}]}}'
       ```

    6. Assign the same allocation ID to the target VM:

       ```bash theme={null}
       nebius compute instance update --patch \
         --id "$TARGET_VM" \
         "$(jq -n --arg alloc "$ALLOC_ID" '{"spec":{"network_interfaces":
         [{"name":"eth0","public_ip_address":{"static":true,"allocation_id":$alloc}}]}}')"
       ```

       The output of this command shows that the allocation is attached to the target VM.
  </Tab>
</Tabs>

## How to detach an IP address from a VM

To detach a public address or a secondary private address from a VM:

<Tabs>
  <Tab title="Web console">
    1. In the [web console](https://console.nebius.com), go to <Icon icon="https://mintcdn.com/nebius-ai-cloud/1Ha0sWR6e1mnIaHS/_assets/sidebar/compute.svg?fit=max&auto=format&n=1Ha0sWR6e1mnIaHS&q=85&s=b91340217b08a1456d88ae0347f281d1" width="16" height="16" data-path="_assets/sidebar/compute.svg" /> **Compute** → **Virtual machines**.
    2. Open the page of the required VM and then go to the **Network interface** tab.
    3. In the line of the allocation that you want to detach from a VM, click <Icon icon="https://mintcdn.com/nebius-ai-cloud/1Ha0sWR6e1mnIaHS/_assets/button-vellipsis.svg?fit=max&auto=format&n=1Ha0sWR6e1mnIaHS&q=85&s=e80b8e57c43bfd117679262e6a1334ad" width="12" height="24" data-path="_assets/button-vellipsis.svg" /> → **Detach**.
    4. In the window that opens, confirm the action.
  </Tab>
</Tabs>
