Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

When building a VM, you can select which virtual device type you would like a vNIC to be (E1000, VMXNET3, etc).

After the VM is created, can you change the type of vNIC in use on a given connection (eg from E1000 to VMXNET3)?

If so, how?

share|improve this question

4 Answers 4

up vote 11 down vote accepted

Yes, you can change the type.

Use the Set-NetworkAdapter powercli cmdlet. The "Type" switch allows you to modify adapter. Note that the VM has to be turned off to do this.

https://www.vmware.com/support/developer/PowerCLI/PowerCLI41U1/html/Set-NetworkAdapter.html

vSphere PowerCLI can be downloaded here:

https://my.vmware.com/group/vmware/details?downloadGroup=VSP510-PCLI-510&productId=285

It can be installed on any Windows machine that has network access to the ESXi server. I typically install it directly on my laptop/workstation where I also have vSphere installed.

After installing, open it up. Use Connect-VIServer to connect to your ESXi host. It will prompt you for server ip, and credentials.

Use Get-VM to retrieve the list of VMs on the ESXi host. Confirm the one you want to change is there, and note the exact name.

Use this command to change the adapter, replacing server name with exact name from the Get-VM list and type with the adapter type you want:

get-vm 'myserver'|get-networkadapter|set-networkadapter -type e1000

Note that if the VM has multiple NICs you may need another switch in the command to specify the correct one.

share|improve this answer
1  
not having worked with PowerCLI before, can that be run from a Linux VM? –  warren Jan 10 at 20:31
    
@warren I think it's Windows only, since PowerCLI is basically a bunch of PowerShell scripts that hit the vSphere APIs. Think of it like a command-line alternative to vSphere - you use it to connect to an ESXi host and issue commands. –  jlehtinen Jan 10 at 20:42
    
ok - guess I'm not fully understanding it, as I haven't used it before. Is it run on the vCenter host? –  warren Jan 10 at 20:45
1  
@warren I updated the post with more details. –  jlehtinen Jan 10 at 21:09

As you might be learning there are a number of ways to change the adapter type. One caveat to remember relates to MAC address generation.

When you create a virtual NIC there are two options related to the MAC address:

  • Automatic: (default) ESX autogenerates a MAC address for you
  • Manual: You, the user, manually enters a MAC address that you select

If you are using auto-generated MACs then changing the adapter type results in the address being regenerated. This means that any configurations you have, on the guest or the network infrastructure itself, that rely on a MAC address will fail. So if you change the adapter type you must let if autogenerate a new MAC address or manually set your own. You cannot, however, manually set the old address as the interface as ESX reserves this prefix for it's own purposes.

WARNING WARNING WHEN THIS FAILS BLAME ONLY YOURSELF

An alternative that I have used is to manually edit the virtual machine's configuration file. This method requires SSH be enabled on the ESX host and you be willing to bypass all the data integrity protections that using a GUI or API provide.

Before you do any of these steps make sure the guest is powered off and the settings window is closed.

  1. SSH into your host
  2. Locate vmx file for your virtual machine (ex. /vmfs/volumes/datastore1/testvm.priv/testvm.priv.vmx
  3. Open the file for editing: vi /vmfs/volumes/datastore1/testvm.priv/testvm.priv.vmx
  4. Find the line that defines the interface type. E.g., for the first vNIC ethernet0.virtualDev = "e1000"
  5. Change e1000 to vmxnet3
  6. Save the file and exit.

Now you will have changed the virtual NIC device type without having to change the MAC address.

share|improve this answer
1  
not so sure I'd be worried about the MAC address ... the only place it should come into play is on a specific DHCP lease, and those time-out after a while –  warren Jan 13 at 18:00
1  
@warren: It depends quite a lot on your infrastructure. In my case it was easier to do this than re-register the guests so their MACs would be allowed on the network. Sometimes switch ports could be MAC locked, sometimes reservations are in use. Sometimes it doesn't matter but sometimes it does and a good admin needs to know how different things work in different situations. –  Scott Pack Jan 13 at 18:36
    
good point. In this case, that's not a concern, but I see how it could be :) –  warren Jan 13 at 19:57
1  
If you want to avoid ssh you can download the .vmx from browse datastore, edit it and upload. –  JamesRyan Feb 7 at 15:23
1  
Uncontested. The first rule of Internet advice is to pour out a bowl of salt. The second is to analyze it against your environment to see what actually makes sense. With a sufficiently advanced environment doing any host maintenance without vCLI is probably bad juju. –  Scott Pack Feb 8 at 18:35

I don't think it's productive to suggest a PowerCLI or scripting solution to this question... Too many assumptions about the surrounding infrastructure for what's a 30-second manual fix.

The answer is that you really shouldn't change the type of adapter in-flight. The more accepted process is to remove the existing adapter and add a new adapter of the type you desire.

existing E1000 NIC attached to a VM enter image description here

remove the E1000 NIC enter image description here

add a new Network device
enter image description here

specify the type of adapter to be used in the new network device enter image description here

In your operating system, reconfigure network settings.

share|improve this answer
    
removing the old NIC and adding a new does not change the type directly - though it could be utilized. The drawback is that, at least on Linux, you then need to remove the old configs for eth0 (or eth<n>), because otherwise you just get the next sequential eth<n> assignment –  warren Jan 13 at 17:59

You cannot change the type, but you can easily delete the unwanted type and add a new vNIC of the wanted type.

share|improve this answer
    
that's what I was thinking the answer would be. Oh well. Any idea why this is the case? –  warren Jan 10 at 20:26
2  
It's a GUI limitation. Evidently, you can do so via PowerCLI - see @jlehtinen's answer for details. –  John Jan 10 at 20:30
1  
@John: You also can do it in the GUI (at least on 5.1). The VM must be powered down and you must change the MAC. –  Scott Pack Jan 11 at 2:03
    
@ScottPack - is that in the webui, or the vCenter client? –  warren Jan 13 at 19:57
1  
@warren: The webUI was introduced with 5.5. Which is fantastic because, from what I understand, it's only available through vCenter and many features are no longer available in the fat client. Really leaves all of us standalone users out in the cold. –  Scott Pack Jan 14 at 12:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.