VMware Cloud Community
jooshilaig
Enthusiast
Enthusiast

PowerCli script for changing TCP/IP stack for VM Kernel Adapters on a vDS

hello friends

any one have a script to change the TCP/IP stack configuration for the hosts that are connected to a vDS

Thanks

7 Replies
daphnissov
Immortal
Immortal

Just an FYI, you can't change a TCP/IP stack for a vmkernel port once it's created. You'll have to delete and re-create that vmkernel instance and assign it to the proper stack.

LucD
Leadership
Leadership

Getting the vmk on the ESXi nodes connected to a VDS is straightforward.

But changing the stack on an existing VMKernel is not available afaik know (see Re: TCP/IP Stack )

You can do a remove/add, something like this

$vdsName = '<MyVDS>'

$newIPStack = '<MyStack>'

Get-VDSwitch -Name $vdsName | Get-VMHost | %{

    $esxcli = Get-EsxCli -VMHost $_ -V2

    foreach($vmk in ($esxcli.network.ip.interface.list.Invoke() | where{$_.PortSet -eq $vdsName})){

        $sVmk = @{

            interfacename = $vmk.Name

            dvsname =  $vmk.Portset                  

        }

        $esxcli.network.ip.interface.remove.Invoke($sVmk)

        $sVmk = @{

            interfacename = $vmk.Name

            portgroupname = $vmk.Portgroup

            netstack = $newIPStack

        }

        $esxcli.network.ip.interface.add.Invoke($sVmk)

    }

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
jooshilaig
Enthusiast
Enthusiast

Thanks Luc, this is really helpful  Smiley Happy

Reply
0 Kudos
Ankushsethi
Enthusiast
Enthusiast

Is there anyway to create the vmkernal with vmotion tcpip New-VMHostNetworkAdapter -vmotionenabled creates on default stack

Reply
0 Kudos
LucD
Leadership
Leadership

I'm not sure I understand the question.
Do you mean creating a vmk, with vMotion enabled on it?
If that is the case, no, you can't via the $esxcli object afaik.
But you can use the Set-VMHostNetworkAdapter once the vmk has been created.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
Ankushsethi
Enthusiast
Enthusiast

I want to create the Vmotion  Vmkernel network Adaptor on By Choosing Vmotion TCPIP Stack

Set-vmhostnetworkadapter - Vmotionenabled:$true

It creates the Vmkernel Network adapted but TCPIP stack is Default

Reply
0 Kudos
LucD
Leadership
Leadership

If you use the code I posted earlier, you can select the stack.
Once the vmk is created, you should be able to use Set-VMHostNetworkAdapter to enable vMotion.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos