I have 300+ VMs of ubuntu build on from one ova. On vm there are 5 network adapters. I need from inside vm rename them regarding to VMware ESX order.
For example naming in different scenarios:
- first = eth1, second = eth2, third = em0, etc
- first = em0, second = em9, third = br0, etc
- first = phys1, second = phys2, third = eth0, etc.
My problem is that lspci|grep "Ethernet controller" don't show them ordered:
04:00.0 Ethernet controller: VMware VMXNET3 Ethernet Controller (rev 01)
0b:00.0 Ethernet controller: VMware VMXNET3 Ethernet Controller (rev 01)
0c:00.0 Ethernet controller: VMware VMXNET3 Ethernet Controller (rev 01)
13:00.0 Ethernet controller: VMware VMXNET3 Ethernet Controller (rev 01)
1b:00.0 Ethernet controller: VMware VMXNET3 Ethernet Controller (rev 01)
04:00.0 should be eth1 but it's eth4 -- I compared by macs
it's really order: /etc/udev/rules.d/70-persistent-net.rules
SUBSYSTEM=="net", ACTION=="add", KERNELS=="0000:0b:00.0", ATTR{dev_id}=="0x0", NAME="eth1"
SUBSYSTEM=="net", ACTION=="add", KERNELS=="0000:13:00.0", ATTR{dev_id}=="0x0", NAME="eth2"
SUBSYSTEM=="net", ACTION=="add", KERNELS=="0000:1b:00.0", ATTR{dev_id}=="0x0", NAME="eth3"
SUBSYSTEM=="net", ACTION=="add", KERNELS=="0000:04:00.0", ATTR{dev_id}=="0x0", NAME="eth4"
SUBSYSTEM=="net", ACTION=="add", KERNELS=="0000:0c:00.0", ATTR{dev_id}=="0x0", NAME="eth5"
This is information from ubuntu vm on ESXi:
cat ubuntu.vmx|grep eth|more
ethernet0.present = "TRUE"
ethernet0.virtualDev = "vmxnet3"
ethernet0.wakeOnPcktRcv = "FALSE"
ethernet0.networkName = "_clients_network_1"
ethernet0.addressType = "vpx"
ethernet1.present = "TRUE"
ethernet1.virtualDev = "vmxnet3"
ethernet1.wakeOnPcktRcv = "FALSE"
ethernet1.networkName = "_servers_network_1"
ethernet1.addressType = "vpx"
ethernet2.present = "TRUE"
ethernet2.virtualDev = "vmxnet3"
ethernet2.wakeOnPcktRcv = "FALSE"
ethernet2.networkName = "_clients_network_1"
ethernet2.addressType = "vpx"
ethernet3.present = "TRUE"
ethernet3.virtualDev = "vmxnet3"
ethernet3.wakeOnPcktRcv = "FALSE"
ethernet3.networkName = "_servers_network_1"
ethernet3.addressType = "vpx"
ethernet4.present = "TRUE"
ethernet4.virtualDev = "vmxnet3"
ethernet4.wakeOnPcktRcv = "FALSE"
ethernet4.networkName = "VM Network"
ethernet4.addressType = "vpx"
ethernet0.generatedAddress = "00:50:56:a8:66:24"
ethernet0.pciSlotNumber = "192"
ethernet1.generatedAddress = "00:50:56:a8:32:78"
ethernet1.pciSlotNumber = "224"
ethernet2.generatedAddress = "00:50:56:a8:7e:2c"
ethernet2.pciSlotNumber = "256"
ethernet3.generatedAddress = "00:50:56:a8:56:91"
ethernet3.pciSlotNumber = "1184"
ethernet4.generatedAddress = "00:50:56:a8:67:ad"
ethernet4.pciSlotNumber = "1216"
ethernet0.generatedAddressOffset = "0"
ethernet1.generatedAddressOffset = "10"
ethernet2.generatedAddressOffset = "20"
ethernet3.generatedAddressOffset = "30"
ethernet4.generatedAddressOffset = "40"
Idea 1
A VM is meant to be quite isolated from its host, and thus the design is to make this sort of superspection difficult.
But, you could do this using the guest-info functionality. You would need to script the host-side, to populate the mappings of guest-hardware topology information (PowerShell etc). and them use the vmtools to get that information from within the guest (with udev hacking along the way).
http://www.virtuallyghetto.com/2011/01/how-to-extract-host-information-from.html
I think for this to work, you may need to enable something first for the VM, but I'm not sure what.
What do you get for the following command? I get errors, but the link above suggests you should be able to get information that has been set from outside the VM.
Idea 2
You can use
ethtool --driver IFNAME
to get bus information. Perhaps that would easiest. Here's an example for an e1000And for a vmxnet3
I wonder if register dump is useful... doesn't look like it, but then hex doesn't make a lot of sence.