This is a cache of https://docs.okd.io/4.19/virt/vm_networking/virt-setting-interface-link-state.html. It is a snapshot of the page at 2025-07-08T21:56:09.179+0000.
Setting VM interface link state - Networking | Virtualization | OKD 4.19
×

You can manage the link state of a primary or secondary virtual machine (VM) interface by using the OKD web console or the cli. By specifying the link state, you can logically connect or disconnect the virtual network interface controller (vNIC) from a network.

OKD Virtualization does not support link state management for Single Root I/O Virtualization (SR-IOV) secondary network interfaces and their link states are not reported.

You can specify the desired link state when you first create a VM, by editing the configuration of an existing VM that is stopped or running, or when you hot plug a new network interface to a running VM. If you edit a running VM, you do not need to restart or migrate the VM for the changes to be applied. The current link state of a VM interface is reported in the status.interfaces.linkState field of the VirtualMachineInstance manifest.

Setting the VM interface link state is a Technology Preview feature only. Technology Preview features are not supported with Red Hat production service level agreements (SLAs) and might not be functionally complete. Red Hat does not recommend using them in production. These features provide early access to upcoming product features, enabling customers to test functionality and provide feedback during the development process.

For more information about the support scope of Red Hat Technology Preview features, see Technology Preview Features Support Scope.

You can set the link state of a primary or secondary virtual machine (VM) network interface by using the web console.

Prerequisites
  • You are logged into the OKD web console.

Procedure
  1. Navigate to VirtualizationVirtualMachines.

  2. Select a VM to view the VirtualMachine details page.

  3. On the Configuration tab, click Network. A list of network interfaces is displayed.

  4. click the Options menu kebab of the interface that you want to edit.

  5. Choose the appropriate option to set the interface link state:

    • If the current interface link state is up, select Set link down.

    • If the current interface link state is down, select Set link up.

You can set the link state of a primary or secondary virtual machine (VM) network interface by using the cli.

Prerequisites
  • You have installed the OpenShift cli (oc).

Procedure
  1. Edit the VM configuration to set the interface link state, as in the following example:

    apiVersion: kubevirt.io/v1
    kind: VirtualMachine
    metadata:
      name: my-vm
    spec:
      template:
        spec:
          domain:
            devices:
              interfaces:
                - name: default (1)
                  state: down (2)
                  masquerade: { }
          networks:
            - name: default
              pod: { }
    # ...
    1 The name of the interface.
    2 The state of the interface. The possible values are:
    • up: Represents an active network connection. This is the default if no value is specified.

    • down: Represents a network interface link that is switched off.

    • absent: Represents a network interface that is hot unplugged.

      If you have defined readiness or liveness probes to run VM health checks, setting the primary interface’s link state to down causes the probes to fail. If a liveness probe fails, the VM is deleted and a new VM is created to restore responsiveness.

  2. Apply the VirtualMachine manifest:

    $ oc apply -f <filename>.yaml
Verification
  • Verify that the desired link state is set by checking the status.interfaces.linkState field of the VirtualMachineInstance manifest.

    $ oc get vmi <vmi-name>
    Example output
    apiVersion: kubevirt.io/v1
    kind: VirtualMachineInstance
    metadata:
      name: my-vm
    spec:
      domain:
        devices:
          interfaces:
          - name: default
            state: down
            masquerade: { }
      networks:
      - name: default
        pod: { }
    status:
      interfaces:
        - name: default
          linkState: down
    # ...