--- title: "Attach a VPC to a VM" description: "Attach a CPU TIR Virtual Machine to a VPC for private networking, switch it to another VPC, or detach it, and find its private IP." content_type: "how-to" product: "tir-vm" platform: "TIR" url: "/tir/tir-vm/how-to/attach-a-vpc-to-a-vm/" topic: ["network"] --- # Attach a VPC to a VM Attach a VPC to a CPU TIR Virtual Machine (VM) to give it a private address in a network of your own, so it can talk to your other machines in that VPC privately. The VM keeps its public address as well. A VM holds one VPC at a time, and you can switch it to another VPC or detach it later. ## Before you begin - A VM on a plan from the **CPU** tab. A GPU VM or a private cluster VM uses a VPC IP instead. See [Use a VPC IP on a GPU VM or a private cluster VM](#use-a-vpc-ip-on-a-gpu-vm-or-a-private-cluster-vm). - An active VPC with a free IP. To make one, see [Create a VPC](/tir/tir-vpc/how-to/create-a-vpc/). - Permission to update VMs in the project. See [TIR Access Control](/tir/tir-iam/). Until you attach a VPC of your own, a CPU VM sits on the project's default private network. ## Attach a VPC when you create the VM On the **Create VM** form, choose the VPC in the **VPC** field under **Network & Security**. Choose an active VPC with a free IP for each VM you launch. See [Create a VM](/tir/tir-vm/how-to/create-a-vm/) for the rest of the form. ## Attach or switch the VPC of a VM that exists Attaching or switching a VPC restarts the VM, so save your work and stop long jobs first. 1. In **Manage VMs**, select the VM's name, then go to **Network & Security** > **Network**. 2. In the VPC section, pick a VPC in **Select VPC**, then pick one of its subnets in **Select subnet**. 3. Select **Update**. 4. In **Attach VPC**, or **Switch VPC** when the VM already has one, select **Continue**. **Switch VPC** detaches the current VPC and attaches the new one. The VM restarts to pick up the VPC: a second network interface next to the public one, with its address from the VPC. ## Find the private IP When the VM is **Running** again, **Private IP** under **Connection Details** on its **Overview** tab is the VM's address inside the VPC. Use it to reach the VM from your other machines in the same VPC, including over SSH. See [Connect to a VM over SSH](/tir/tir-vm/how-to/connect-to-a-vm-over-ssh/). ## Detach the VPC Detaching the VPC restarts the VM, and the VM loses its address in that VPC. 1. On the **Network** side tab, select **Detach** beside the VPC. 2. In **Detach VPC**, select **Detach**. The VM restarts and is back on the project's default private network. ## Use a VPC IP on a GPU VM or a private cluster VM A VM on a GPU plan or on a private cluster joins a VPC through a VPC IP. On its **Network** side tab, pick an address in **Select VPC IP**, or reserve one with **Reserve New VPC IP**, then select **Attach**. You can attach a VPC IP while the VM is **Stopped** as well as while it runs. To detach it, select **Detach VPC** beside the VPC and confirm in **Detach VPC**. The VM then loses its connection to that VPC. To give the VM a public address that stays the same, see [Attach a reserved IP to a VM](/tir/tir-vm/how-to/attach-a-reserved-ip-to-a-vm/). For help with a message, see [Troubleshooting TIR Virtual Machines](/tir/tir-vm/troubleshooting/tir-vm/#vpc-is-not-available-for-gpu-vms-in-this-location).