[Yandex Cloud documentation](../../../index.md) > [Yandex Compute Cloud](../../index.md) > [Step-by-step guides](../index.md) > Managing a VM > Deleting a network interface from a VM

# Deleting a network interface from a VM


A virtual machine supports up to eight [network interfaces](../../concepts/network.md). You can delete network interfaces you no longer need on both stopped and running VMs.

{% note info %}

Still, you cannot delete a VM's network interface if it is the only one it has.

{% endnote %}

To delete a network interface from a VM:

{% list tabs group=instructions %}

- CLI {#cli}

  If you do not have the Yandex Cloud CLI yet, [install and initialize it](../../../cli/quickstart.md#install).

  The folder used by default is the one specified when [creating](../../../cli/operations/profile/profile-create.md) the CLI profile. To change the default folder, use the `yc config set folder-id <folder_ID>` command. You can also specify a different folder for any command using `--folder-name` or `--folder-id`. If you access a resource by its name, the search will be limited to the default folder. If you access a resource by its ID, the search will be global, i.e., through all folders based on access permissions.

  1. See the description of the CLI command for deleting a network interface from a VM:

      ```bash
      yc compute instance detach-network-interface --help
      ```

  1. Get a list of VMs in the default [folder](../../../resource-manager/concepts/resources-hierarchy.md#folder):

      ```bash
      yc compute instance list
      ```
      
      Result:
      ```text
      +----------------------+-----------------+---------------+---------+----------------------+
      |          ID          |       NAME      |    ZONE ID    | STATUS  |     DESCRIPTION      |
      +----------------------+-----------------+---------------+---------+----------------------+
      | fhm0b28lgfp4******** | first-instance  | ru-central1-a | RUNNING | my first vm via CLI  |
      | fhm9gk85nj7g******** | second-instance | ru-central1-a | RUNNING | my second vm via CLI |
      +----------------------+-----------------+---------------+---------+----------------------+
      ```

      Save the ID of the VM from which you want to delete a network interface.

  1. Stop the selected VM if needed by specifying its ID:

      {% note info %}

      The feature of adding and removing network interfaces on running VMs is at the [Preview stage](../../../overview/concepts/launch-stages.md). To access the feature, [contact](https://center.yandex.cloud/support) support.

      {% endnote %}

      ```bash
      yc compute instance stop <VM_ID>
      ```

  1. Get a list of network interfaces for the selected VM by specifying its ID:

      ```bash
      yc compute instance get <VM_ID>
      ```

      Result:

      ```yml
      ...
      network_interfaces:
        - index: "0"
          mac_address: d0:0d:1a:**:**:**
          subnet_id: e2lrucutusnd********
          primary_v4_address:
            address: 192.168.1.20
            one_to_one_nat:
              address: 158.***.**.***
              ip_version: IPV4
          security_group_ids:
            - enpuatgvejtn********
        - index: "1"
          mac_address: d0:1d:1a:**:**:**
          subnet_id: e2lpp96bvvgp********
          primary_v4_address:
            address: 192.168.2.3
          security_group_ids:
            - enpuatgvejtn********
            - enpg8d2hqh1o********
        - index: "2"
          mac_address: d0:2d:1a:**:**:**
          subnet_id: e2lv9c6aek1d********
          primary_v4_address:
            address: 192.168.4.17
          security_group_ids:
            - enpuatgvejtn********
            - enpg8d2hqh1o********
      ...
      ```

      Save the number (the `index` field value) of the network interface you want to delete.

  1. Delete the network interface:

      ```bash
      yc compute instance detach-network-interface \
        --id <VM_ID> \
        --network-interface-index <network_interface_number>
      ```

      Where:
      * `--id`: ID of the selected VM. Instead of the ID, you can use the `--name` parameter to specify the VM name.
      * `--network-interface-index`: Previously saved number of the VM's network interface you need to delete.

      Result:

      ```yml
      ...
      network_interfaces:
        - index: "0"
          mac_address: d0:0d:1a:**:**:**
          subnet_id: e2lrucutusnd********
          primary_v4_address:
            address: 192.168.1.20
            one_to_one_nat:
              address: 158.***.**.***
              ip_version: IPV4
          security_group_ids:
            - enpuatgvejtn********
        - index: "1"
          mac_address: d0:1d:1a:**:**:**
          subnet_id: e2lpp96bvvgp********
          primary_v4_address:
            address: 192.168.2.3
          security_group_ids:
            - enpuatgvejtn********
            - enpg8d2hqh1o********
      ...
      ```

- API {#api}

  Use the [detachNetworkInterface](../../api-ref/Instance/detachNetworkInterface.md) REST API method for the [Instance](../../api-ref/Instance/index.md) resource or the [InstanceService/DetachNetworkInterface](../../api-ref/grpc/Instance/detachNetworkInterface.md) gRPC API call.

{% endlist %}