VMware Cloud Community
rbharali
Contributor
Contributor

Can we assign IPv6 ips to VMs using power CLi commandlet "Set-VMGuestNetworkInterface"

I'm able to assign ipv4 ips to all VMs using "Set-VMGuestNetworkInterface  -VMGuestNetworkInterface $GuestInterface -HostCredential $HostCred -GuestCredential $GuestCred -IP $ipaddr -Netmask $subnet -Gateway $gateway" command

Is there any way i can assign IPv6 ips to my VMs using ""Set-VMGuestNetworkInterface"

Thanks, Rajsekhar
Tags (1)
0 Kudos
5 Replies
LucD
Leadership
Leadership

Judging from the SetVMGuestNetworkInterface_windows7_64Guest.bat script that is used by this cmdlet, I would say it isn't supported.

But since you have access to this, and other scripts, it shouldn't be too hard to adapt the script for IPv6.


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

0 Kudos
rbharali
Contributor
Contributor

But if I use this command to give a IPv6 address "Set-VMGuestNetworkInterface  -VMGuestNetworkInterface $GuestInterface -HostCredential $HostCred -GuestCredential $GuestCred -IP $ip6addr"

This gives a error that :

Incorrect IPv4 Address

Thanks, Rajsekhar
0 Kudos
rbharali
Contributor
Contributor

I have used the below script which works fine for assigning IPv4 address to all Linux VMs :

However the same script fails for IPv6

Connect-VIServer x.x.x.x

# Pop-up that will prompt for the ESX credentials

$HostCred = $Host.UI.PromptForCredential("Please enter credentials", "Enter ESXi host credentials", "", "")

# Pop-up that will prompt for the VM credentials

$GuestCred = $Host.UI.PromptForCredential("Please enter credentials", "Enter Guest credentials", "", "")

# Populating variable from the .csv file

$vmlist = Import-CSV C:vms6.csv

foreach ($item in $vmlist) {

  # I like to map out my variables

  $vmname = $item.vmname

  $ip6addr = $item.ipaddress6

  #$subnet = $item.subnet

  #$policy = $item.policy

#$gateway = $item.gateway

#$pdnswins = $item.pdnswins

  #$sdnswins = $item.sdnswins

  #Get the current interface info

  $GuestInterface = Get-VMGuestNetworkInterface -VM $vmname -HostCredential $HostCred -GuestCredential $GuestCred |Where-Object {$_.Description -like "Ethernet"}

#echo $GuestInterface

  #If the IP in the VM matches, then I don't need to update

    If ($ip6addr -ne $($GuestInterface.ip)) {

      Set-VMGuestNetworkInterface  -VMGuestNetworkInterface $GuestInterface -HostCredential $HostCred -GuestCredential $GuestCred -IP $ip6addr

  }

}

Thanks, Rajsekhar
0 Kudos
LucD
Leadership
Leadership

That's what I said earlier, it doesn't look like it supports IPv6.


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

0 Kudos
fabiendibot
Enthusiast
Enthusiast

You should use invoke-vmscript and use CIM/WMI to set ipv6 adress (if your server is a window one)

0 Kudos