Solved

Nutanix command cheat sheet

  • 13 February 2020
  • 1 reply
  • 6551 views

 Hyper-V Network Cheat sheet.

icon

Best answer by Stalin.Stepin 13 February 2020, 16:41

View original

This topic has been closed for comments

1 reply

Badge

Hi @MdFarooq - I assume that you have access to Nutanix knowledge base. If yes, you can access the data that you are looking for using the link provided below.

https://portal.nutanix.com/kb/000001553

For those who do not have access to Nutanix KB’s, I’m pasting few useful powershell commands for Hyper-V network management.
 

To list all the network adapters, type:

get-netadapter

To set something on the network adapter, type:

set-netadapter

This structure of the Hyper-V commands works anywhere in Windows PowerShell. Remember this structure and you can use most of the Hyper-V commands. You can also use the Tab key to complete the commands. The tab-completion tool not just completes commands, but also looks through all possible completions. This makes it easy to figure out the flags. Use the Get-help command to access the man pages.

In a CMD window, type powershell to access Windows PowerShell. If you are in Windows PowerShell, your prompt string starts with PS.

If you accidentally close all the CMD windows, press ctrl+alt+del and go to the task manager to open a new CMD window.

Following is a list of some useful Hyper-V commands.

Network Adapter Commands

get-netadapter get-vmnetworkadapter -managementOS get-vmnetworkadapter [VM Name] get-vmswitch add-vmnetworkadapter -managementOS set-vmnetworkadaptervlan get-netadapteradvancedproperty connect-vmnetworkadapter disconnect-vmnetworkadapter disable-VmNetworkAdapter

Netadapter Team Commands

get-netlbfoteam get-netlbfoteammember new-netlbfoteam add-netlbfoteammember Remove-NetLbfoTeamMember [-Name] <String[]> [-Team] <String[]> [-CimSession <CimSession[]>] [-ThrottleLimit <Int32>] [-AsJob] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]

Network Troubleshooting Commands

get-netadapterstatus netsh interface ipv4 show ipstats netsh interface ipv4 show tcpstats

See the driver events. This is for the 10 GbE adapter.

get-winevent -providername ixgbn get-winevent -providername I*network*

 

Get the VMs on a host.

get-vm

Get the VMs from SCVMM.

get-scvirtualmachine

For System Center, all the commands are in the [action]-sc[object] format. This is the same as using SSH in ESXi.

enter-pssession


Checking and Setting the Jumbo Frames

Run the following commands to check and set the jumbo frames.

get-NetAdapterAdvancedProperty -DisplayName “Jumbo Packet” | format-table Name, RegistryValue set-NetAdapterAdvancedProperty -Name “Ethernet X” -DisplayName “Jumbo Packet” -RegistryValue 9014


Recreating the NIC Team

Run the following commands to recreate the NIC team.

  1. Get the current adapters in the system.

    get-NetAdapter
  2. Create a new team.

    new-NetLBFOTeam -Name NetAdapterTeam -TeamMembers @(“Ethernet X”, “Ethernet Y”)

    Replace X and Y with the numbers you obtained from the previous command. The @() represents an array.

  3. Connect the team to the ExternalSwitch.

    set-VMSwitch -SwitchName ExternalSwitch -NetAdapterName NetAdapterTeam

Tagging the External Network

Run the following commands to tag the external network.

  1. Check the current settings.

    get-VMNetworkAdapterVlan
  2. Set the Hyper-V host to use the correct VLAN.
     

    set-VMNetworkAdapterVlan -ManagementOS -VMNetworkAdapterName "ExternalSwitch" -Access -VlanID {xx}

    Replace {xx} with your VLAN ID.

  3. Set the Controller VM to use the correct VLAN.

    set-VMNetworkAdapterVlan -Access -VMNetworkAdapterName "External" -VMName {xxx} -VlanID {xx}

    Replace {xx} with your VLAN ID.

    Note: in case you need to undo a tagging, access via IPMI would allow the following command(s) to be entered:
        Host:

    set-VMNetworkAdapterVlan -ManagementOS -VMNetworkAdapterName "ExternalSwitch" -Untagged

       CVM:

    set-VMNetworkAdapterVlan -Access -VMNetworkAdapterName "External" -VMName {xxx} -Untagged

    Recreating the ExternalSwitch


Run the following commands to recreate the ExternalSwitch.

  1. Get a list of the network adapters.

    get-netadapter
  2. Create a new switch.

    new-vmswitch -Name ExternalSwitch -AllowManagementOS $true -NetAdapterName {name from above}

    Replace {name from above} with the name of the interface obtained from the previous command (get-netadapter).

  3. Connect the Controller VM to the ExternalSwitch.

    Connect-VMNetworkAdapter -VMName NTNX* -SwitchName ExternalSwitch -Name External

    If required, tag the VLAN on the Hyper-V host and the Controller VM.

  4. set-VMNetworkAdapterVlan -ManagementOS -Access -VlanID {xx} set-VMNetworkAdapterVlan -Name NTNX* -Access -VlanID {xx}
  5. Set the jumbo frames. Repeat this step for the external vEthernet and the other Ethernet interface.

    set-NetAdapterAdvancedProperty -Name “Ethernet X” -DisplayName “Jumbo Packet” -RegistryValue 9014

    Use sconfig to configure the IP address. Select the option 8 in the menu that appears to configure the IP address.

  6. Verify the settings.

    get-vmswitch get-vmnetworkadapter get-vmnetworkadaptervlan get-vmnetworkadapteradvancedproperty

Recreating the InternalSwitch

Run the following commands to recreate the InternalSwitch.

  1. Create the switch.

    new-vmswitch -Name InternalSwitch -SwitchType Internal
  2. Connect the internal adapter to the network.

    Connect-VMNetworkAdapter -VMName NTNX* -SwitchName InternalSwitch -Name Internal
  3. Use sconfig to configure the IP address. Select the option 8 in the menu that appears to configure the IP address.
  4. Verify the settings.

    get-vmswitch get-vmnetworkadapter

Adding and Removing the NICs from the NIC Team

Run the following commands to add and remove the NICs from the NIC team.

  1. List all the NICs attached to a NIC team and adapters in the system.

    get-NetLbfoTeamMember get-NetAdapter get-NetLbfoTeam
  2. Remove a member from the team.

    remove-NetLbfoTeamMember -Name “Ethernet X” -Team “TeamName”
  3. Add a member to the team.

    add-NetLbfoTeamMember -Name “Ethernet X” -Team “TeamName”
  4. Connect the internal adapter to the network.

    Connect-VMNetworkAdapter -VMName NTNX* -SwitchName InternalSwitch -Name Internal
  5. Use sconfig to configure the IP address. Select the option 8 in the menu that appears to configure the IP address.

  6. Verify the settings.

    get-vmswitch get-vmnetworkadapter