VMware Cloud Community
macdougall
Contributor
Contributor
Jump to solution

Remove or Omit Default Gateway from 2nd NIC

I'm deploying multiple VMs with 2 NICs each. My script has the following lines to set the IP, Subnet and Gateway:

$specClone = New-OScustomizationSpec -Spec $custspec -type nonpersistent

$specClone | New-oscustomizationnicmapping -IpMode UseStaticIP -Ipaddress $ip1 -SubnetMask $subnet1 -DefaultGateway $gateway1 -Dns "0.0.0.0" -Position 1

$specClone | New-oscustomizationnicmapping -IpMode UseStaticIP -Ipaddress $ip2 -SubnetMask $subnet2 -DefaultGateway $gateway2 -Dns "0.0.0.0" -Position 2

Set-VM -Name $name -oscustomizationspec $specClone -erroraction silentlycontinue -runasync -confirm:$false

My problem is that oscustomizationnicmapping by default requires that you enter a default gateway for the 2nd NIC but I don't want to do this for my configuration.

I found an older article here, Deploying a VM with Multiple NICs in PowerCLI., where LucD mentions you can create your own adaptermapping object without defining a gateway.

Is there an easier way to achieve omitting the 2nd default gateway that could be implemented with the "new-oscustomizationnicmapping" method that I'm currently using?

Or do I have to go the more in-depth route and create custom "adaptermapping" objects to get this result?

Thanks,

Bruce

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Then you will be forced to use the API method directly (like in the thread you already pointed to) I'm afraid.


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

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

Can't you change the gateway entry with the Set-OSCustomizationNicMapping cmdlet?

Or doe that also require a Getway?


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

0 Kudos
macdougall
Contributor
Contributor
Jump to solution

I'd like to leave the gateway off of the 2nd NIC completely, but when you use static ip to configure it forces you to define a gateway.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Then you will be forced to use the API method directly (like in the thread you already pointed to) I'm afraid.


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

0 Kudos
macdougall
Contributor
Contributor
Jump to solution

Alright, thanks for the information.

0 Kudos