Yandex Cloud
Search
Contact UsGet started
  • Blog
  • Pricing
  • Documentation
  • All Services
  • System Status
    • Featured
    • Infrastructure & Network
    • Data Platform
    • Containers
    • Developer tools
    • Serverless
    • Security
    • Monitoring & Resources
    • ML & AI
    • Business tools
  • All Solutions
    • By industry
    • By use case
    • Economics and Pricing
    • Security
    • Technical Support
    • Customer Stories
    • Gateway to Russia
    • Cloud for Startups
    • Education and Science
  • Blog
  • Pricing
  • Documentation
Yandex project
© 2025 Yandex.Cloud LLC
Yandex Compute Cloud
    • All guides
      • Stopping and starting a VM
      • Resetting a Windows Server VM user password
      • Attaching a disk to a VM
      • Detaching a disk from a VM
      • Moving a VM to a different availability zone
      • Moving a VM to a different folder
      • Moving a VM to a different cloud
      • Adding another network interface to a VM
      • Deleting a network interface from a VM
      • Assigning a public IP address to a VM
      • Unassigning a public IP address from a VM
      • Making a VM public IP address static
      • Reassigning a public IP address from one VM to another
      • Updating the VM internal IP address
      • Updating a VM
      • Changing VM computing resources
      • Changing VM security groups
      • VM maintenance policy management
      • Configuring VM access permissions
      • Linking a service account to a VM
      • Deleting a VM
    • Viewing operations with resources
  • Yandex Container Solution
  • Access management
  • Terraform reference
  • Monitoring metrics
  • Audit Trails events
  • Release notes

In this article:

  • Convert the public IP address of the original VM to static
  • Unassign the public IP address from the original VM
  • Create a new VM without a public IP address
  • Assign the IP address to the new VM
  1. Step-by-step guides
  2. Managing a VM
  3. Reassigning a public IP address from one VM to another

Reassigning a public IP address from one VM to another

Written by
Yandex Cloud
Updated at May 5, 2025
  • Convert the public IP address of the original VM to static
  • Unassign the public IP address from the original VM
  • Create a new VM without a public IP address
  • Assign the IP address to the new VM

To reassign a public IP address from one VM to another, convert the IP address to static, unassign it from the original VM, and assign it to the new one.

Convert the public IP address of the original VM to staticConvert the public IP address of the original VM to static

You can convert a dynamic public IP address to static. Static public IP addresses are reserved and remain attached to respective resources when VMs and network load balancers are stopped.

Note

Make sure to check out our pricing policy for inactive static public IP addresses.

Management console
CLI
API
  1. In the management console, select the folder containing the address.
  2. In the list of services, select Virtual Private Cloud.
  3. In the left-hand panel, select IP addresses.
  4. Click in the row with the IP address and select Make static.
  5. In the window that opens, click Change.

If you do not have the Yandex Cloud CLI yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

  1. See the description of the CLI commands for updating the address attributes:

    yc vpc address update --help
    
  2. Get a list of addresses in the default folder:

    yc vpc address list
    

    Result:

    +----------------------+------+---------------+----------+------+
    |          ID          | NAME |    ADDRESS    | RESERVED | USED |
    +----------------------+------+---------------+----------+------+
    | e2l46k8conff******** |      | 84.201.177.41 | false    | true |
    +----------------------+------+---------------+----------+------+
    

    The false value of the RESERVED parameter for the IP address with the e2l46k8conff******** ID shows that this address is dynamic.

  3. Convert the address to static by using the --reserved=true key and the address ID:

    yc vpc address update --reserved=true e2l46k8conff********
    

    Result:

    id: e2l46k8conff********
    folder_id: b1g7gvsi89m3********
    created_at: "2021-01-14T09:36:46Z"
    external_ipv4_address:
      address: 84.201.177.41
      zone_id: ru-central1-a
      requirements: {}
    reserved: true
    used: true
    

    Now that the reserved parameter is true, the IP address is static.

To change the type of a public IP address from dynamic to static, use the update REST API method for the Address resource or the AddressService/Update gRPC API call, and provide the following in the request:

  • ID of the IP address you want to convert to static in the addressId parameter.

    To get the address ID, use the list REST API method for the Address resource or the AddressService/List gRPC API call and provide the folder ID in the folderId request parameter.

    To learn how to find out the folder ID, see Getting the folder ID.

  • true in the reserved parameter.

  • Name of the reserved parameter in the updateMask parameter.

Warning

The API method will assign default values to all the parameters of the object you are modifying unless you explicitly provide them in your request. To avoid this, list the settings you want to change in the updateMask parameter as a single comma-separated string.

The number of static public IP addresses is limited. If the number allowed by the quota is not enough for you, contact support to have your quota increased.

Unassign the public IP address from the original VMUnassign the public IP address from the original VM

Management console
CLI
API
  1. In the management console, select the folder this VM belongs to.
  2. Select Compute Cloud.
  3. Select the VM.
  4. In the window that opens, under Network, click in the top-right corner of the relevant network interface section and select Disassociate public IP address.
  5. In the window that opens, click Delete.

If you do not have the Yandex Cloud CLI yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

To unassign a public IP address from a VM, run the following CLI command:

yc compute instance remove-one-to-one-nat
  --id=<VM_ID>
  --network-interface-index=<VM_network_interface_number>

Where:

  • --id: VM ID. You can get a list of available VM IDs in the folder using the yc compute instance list CLI command.
  • --network-interface-index: VM network interface number. The default value is 0. To get a list of VM network interfaces and their numbers, run yc compute instance get <VM_ID>.

For more information about the yc compute instance remove-one-to-one-nat command, see the CLI reference.

Use the removeOneToOneNat REST API method for the Instance resource or the InstanceService/RemoveOneToOneNat gRPC API call.

Create a new VM without a public IP addressCreate a new VM without a public IP address

Management console
CLI
Terraform
API

When creating the VM, select No address in the Public IP address field under Network settings.

When creating a VM, exclude the --network-interface parameter under nat-ip-version=ipv4.

When creating a VM, specify nat = false under network_interface.

When creating a VM, exclude the primaryV4AddressSpec section in the request body.

Assign the IP address to the new VMAssign the IP address to the new VM

Note

If the new VM resides in a different folder, move the public IP address to that folder.

Management console
CLI
Terraform
API
  1. In the management console, select the folder the VM belongs to.
  2. Select Compute Cloud.
  3. In the left-hand panel, select Virtual machines.
  4. Select the VM in question.
  5. In the window that opens, under Network, click in the top-right corner of the relevant network interface section and select Add public IP address. In the window that opens:
    • In the Public address field, select Auto to get an IP address automatically assigned or List to choose a reserved address from the list.
    • Optionally, if you selected Auto in the Public address field, enable DDoS protection. For more information, see Yandex DDoS Protection in Virtual Private Cloud.
    • If you selected List in the Public address field, choose the IP address you want to assign to your VM. The IP address and the VM must be in the same availability zone.
    • Click Add.

If you do not have the Yandex Cloud CLI yet, install and initialize it.

The folder specified when creating the CLI profile is used by default. To change the default folder, use the yc config set folder-id <folder_ID> command. You can specify a different folder using the --folder-name or --folder-id parameter.

To assign a public IP address to a VM, run the following CLI command:

yc compute instance add-one-to-one-nat \
  --id=<VM_ID> \
  --network-interface-index=<VM_network_interface_number> \
  --nat-address=<IP_address>

Where:

  • --id: VM ID. You can get a list of available VM IDs in a folder using the yc compute instance list CLI command.

  • --network-interface-index: VM network interface number. The default value is 0. To get a list of VM network interfaces and their numbers, run the following command: yc compute instance get <VM_ID>.

  • --nat-address: Public IP address to assign to the VM. This is an optional parameter. If you omit it, a public IP address will be assigned to the VM automatically.

    You can get a list of reserved public IP addresses available in a folder using the yc vpc address list CLI command. The IP address and the VM must be in the same availability zone.

Usage example:

yc compute instance add-one-to-one-nat \
  --id=fhmsbag62taf******** \
  --network-interface-index=0 \
  --nat-address=51.250.*.***

Result:

id: fhmsbag62taf********
folder_id: b1gv87ssvu49********
created_at: "2022-05-06T10:41:56Z"
...
network_settings:
  type: STANDARD
placement_policy: {}

For more information about the yc compute instance add-one-to-one-nat command, see the CLI reference.

With Terraform, you can quickly create a cloud infrastructure in Yandex Cloud and manage it using configuration files. These files store the infrastructure description written in HashiCorp Configuration Language (HCL). If you change the configuration files, Terraform automatically detects which part of your configuration is already deployed, and what should be added or removed.

Terraform is distributed under the Business Source License. The Yandex Cloud provider for Terraform is distributed under the MPL-2.0 license.

For more information about the provider resources, see the documentation on the Terraform website or mirror website.

If you do not have Terraform yet, install it and configure its Yandex Cloud provider.

  1. To create a public IP address and link it to a VM network interface, use the yandex_vpc_address resource and specify the address you get in the nat_ip_address field under network_interface for the network interface in question in the yandex_compute_instance resource configuration:

    # Creating a static IP address
    
    resource "yandex_vpc_address" "addr" {
      name = "vm-adress"
      external_ipv4_address {
        zone_id = "<availability_zone>"
      }
    }
    
    # Creating a VM
    
    resource "yandex_compute_instance" "vm-1" {
      name        = "<VM_name>"
      platform_id = "standard-v3"
      resources {
        core_fraction = 20
        cores         = 2
        memory        = 1
      }
      ...
    
      ## Assigning a subnet and IP address to the VM network interface under `network_interface`
    
      network_interface {
        subnet_id      = "<VM_subnet_ID>"
        nat            = true
        nat_ip_address = yandex_vpc_address.addr.external_ipv4_address[0].address
      }
      ...
    
    }
    

    Where nat_ip_address is the public IP address to assign to the VM network interface. The yandex_vpc_address resource contains a list of items, where [0] is the list's first item that contains the IP address. If you already have a reserved public IP address to assign to your VM, specify it in the nat_ip_address field:

    nat_ip_address = "<IP_address>"
    

    The IP address and the VM must be in the same availability zone.

    For more information about the yandex_compute_instance resource parameters, see the relevant provider documentation.

  2. Create the resources:

    1. In the terminal, change to the folder where you edited the configuration file.

    2. Make sure the configuration file is correct using the command:

      terraform validate
      

      If the configuration is correct, the following message is returned:

      Success! The configuration is valid.
      
    3. Run the command:

      terraform plan
      

      The terminal will display a list of resources with parameters. No changes are made at this step. If the configuration contains errors, Terraform will point them out.

    4. Apply the configuration changes:

      terraform apply
      
    5. Confirm the changes: type yes in the terminal and press Enter.

    Terraform will create all the required resources. You can check the new resources using the management console.

To assign a public IP address to a VM network interface, use the addOneToOneNat REST API method for the Instance resource or the InstanceService/AddOneToOneNat gRPC API call.

Your VM network interface will have a public IP address assigned. You can use this IP address to connect to the VM via SSH.

Was the article helpful?

Previous
Making a VM public IP address static
Next
Updating the VM internal IP address
Yandex project
© 2025 Yandex.Cloud LLC