Rename VMNetworkAdapter or set different trunk VLANs

Anahaym 496 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 for business | Windows Client for IT Pros | Storage high availability | Virtualization and Hyper-V
Windows for business | Windows Server | User experience | Other
Windows for business | Windows Client for IT Pros | User experience | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    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.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.