VMware Cloud Community
raz391
Contributor
Contributor

vmhost network config

Hi,

There is a way to config a VMHost network remotely for:

1. Static IP

2. Gateway

3. Management port group VLAN Id

By Remotely I mean: SSH or Powercli or ESXCLI (Via IP Connection, Not DCUI Console)

My problem is when I config one of the above, I immediately lost session connectivity (It makes quite a sense),

So what I actually ask is,  if there is a way to config all of the above in single commit (and after all config, its OK for me to lost connectivity).

Thanks.

3 Replies
Rajhere
Enthusiast
Enthusiast

hey Raz,

you ask is valid Smiley Happy

However these settings could not configured at one shot in the SSH ...

If you are familiar with PowerCLI please run the codes available here -> http://www.virtu-al.net/2009/10/14/powercli-host-network-config/

Raj

Reply
0 Kudos
T180985
Expert
Expert

Are these VMhosts already managed by vCenter? If so then you should be able to create and edit the vmk adapters via powershell including changing IP information but you will need to bare in mind that any change to IP is likely going to require you change DNS settings also otherwise vCenter will lose connectivity to the host.

If youre simply connecting directly to a host on its management IP and then trying to change those IP settings, youre going to lose connectivity even if you did them all in one go...

$host = Get-VMHost <HOST>

$switch = Get-VirtualSwitch -Name "Switch"

$PortGroup = Get-VirtualPortGroup -Name "PortGroup"

New-VMHostNetworkAdapter -VMHost $host -PortGroup $PortGroup -VirtualSwitch $switch -IP *IP ADDRESS* -SubnetMask *MASK*  -ManagementTrafficEnabled:$true

see: Re: VMkernel Port Configuration using Powershell.

Please mark helpful or correct if my answer resolved your issue. How to post effectively on VMTN https://communities.vmware.com/people/daphnissov/blog/2018/12/05/how-to-ask-for-help-on-tech-forums
Reply
0 Kudos
LucD
Leadership
Leadership

You can use the Set-VMHostNetworkAdapter cmdlet for that (or the New-VMHostNetworkAdapter cmdlet for a new definition).

If you are of course using the connection (via SSH or PowerCLI) you are reconfiguring, that connection will be lost.
You will at least have to reconnect afterwards.

The underlying API call UpdateVirtualNic can also be used directly from PowerCLI.

PS: Alan's script is in fact only displaying the settings, not changing them


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