Rename VMNetworkAdapter or set different trunk VLANs

Anahaym 471 Reputation points
2024-04-25T15:45:13.03+00:00

Hello,

I have a Hyper-V Server with one Virtual Switch configured, which is bound to an external interface.

I also created a VM with three NICs, which are connected to the same VSwitch.

Now I need to confugre one interface as a Trunk:

Set-VMNetworkAdapterVlan -VMName 1_DC01 -VMNetworkAdapterName "Netzwerkkarte" -Trunk -AllowedVlanIdList 2-1024 -NativeVlanId 1

But this commad sets Trunk to all three interfaces. So, how can I rename network cards or set Trunk to a certain NIC?

hyper-v-netz1

Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,171 questions
Hyper-V
Hyper-V
A Windows technology providing a hypervisor-based virtualization solution enabling customers to consolidate workloads onto a single server.
2,546 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
8,221 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ian Xue (Shanghai Wicresoft Co., Ltd.) 29,891 Reputation points Microsoft Vendor
    2024-04-29T04:35:49.09+00:00

    Hi Anahaym,

    Hope you're doing well.

    To rename network adapters or set trunk mode to a specific NIC on a virtual machine in Hyper-V, you can use PowerShell commands. Here's how you can achieve this:

    1. Before proceeding, identify the NICs you want to configure on the virtual machine.
    2. You can rename the network adapters on the virtual machine using the "Rename-VMNetworkAdapter" cmdlet. Please open PowerShell as an administrator and run the following command:

    Rename-VMNetworkAdapter -VMName "1_DC01" -Name "OldName" -NewName "NewName"

    Replace "1_DC01" with the name of your virtual machine and "OldName" with the current name of the network adapter you want to rename, and "NewName" with the desired new name.

    1. To set trunk mode for a specific NIC on the virtual machine, you can use the "Set-VMNetworkAdapterVlan" cmdlet. Just open PowerShell as an administrator and run the following command:

    Set-VMNetworkAdapterVlan -VMName "1_DC01" -VMNetworkAdapterName "NewName" -Trunk -AllowedVlanIdList 2-1024 -NativeVlanId 1

    Replace "1_DC01" with the name of your virtual machine and "NewName" with the name of the network adapter you want to configure as a trunk.

    Best Regards,

    Ian Xue


    If the Answer is helpful, please click "Accept Answer" and upvote it.