Predictable network naming, configure enp**-naming?

This is for discussing general topics about how to use VirtualBox.
Post Reply
EasyRider
Posts: 3
Joined: 17. Mar 2021, 14:54

Predictable network naming, configure enp**-naming?

Post by EasyRider »

Hi!

I am currently working on trying to configure my virtual machine to, as far as it is possible, mirror my real hardware. For that I need to configure my network adapters to create adapters with "the same physical location".
The hardware and OS (centos8) creates network interfaces of enp-type. And this is also what I get when I install my operating system in a virtual machine. But! The location identifier and slot number is wrong.

Is It possible to somehow configure the network adapter(s) so that I can decide what numbers is used in the enp#s#f#-naming?

In the vbox-file i find <Network> <Adapter> which contain "slot", but I do not think that this is the correct to change due to the different naming in the operating system.

Thank you!
fth0
Volunteer
Posts: 5668
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Predictable network naming, configure enp**-naming?

Post by fth0 »

In the VM configuration, the 4 Network Adapters automatically correspond to enp0s3, enp0s8, enp0s9 and enp0s10. If you need other PCI bus addresses, tell us what exactly you like to achieve, and we'll see if we come up with an idea.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Predictable network naming, configure enp**-naming?

Post by scottgus1 »

Just to add a bit to fth0's comments: Virtualbox only provides the 'hardware' in the designated 'slots', same as if one bought a motherboard and added network cards to the slots. It is up to the VM's installed OS to decide or be told how to name the devices. A web-search in your chosen OS's help channels on how to name devices might help, too.
EasyRider
Posts: 3
Joined: 17. Mar 2021, 14:54

Re: Predictable network naming, configure enp**-naming?

Post by EasyRider »

Thanks for the replies.

I am aware of the udev-rules and how to change name of interfaces. But this is another problem. We install software om a virtual machine before testing it on the real hardware. If it is not possible to change the name on the interfaces from the VM ( the pci buss location) then we need to add special software just for the use of virtual machine which is not needed on the real hardware.

For example, If i want
enp23s1f1

Is it possible?
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Predictable network naming, configure enp**-naming?

Post by scottgus1 »

Not through Virtualbox. That naming is made by the OS inside the VM and needs to be changed inside the OS. Web-search the OS to see how to change that name.
fth0
Volunteer
Posts: 5668
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Predictable network naming, configure enp**-naming?

Post by fth0 »

It may not be impossible, but it could be a lot of work to figure out, especially if your example (enp23s1f1) is realistic. Using udev rules would be much easier in that case. ;)

In a VM, VirtualBox emulates a PCI device tree with fixed PCI addresses, and the individual devices either exist or not. You can see the results in the VBox.log file, for example:
VBox.log wrote:
00:00:01.575715 [/Devices/e1000/0/] (level 3)
00:00:01.575726   PCIBusNo      <integer> = 0x0000000000000000 (0)
00:00:01.575727   PCIDeviceNo   <integer> = 0x0000000000000003 (3)
00:00:01.575727   PCIFunctionNo <integer> = 0x0000000000000000 (0)
You can change the PCI device number using

Code: Select all

VBoxManage setextradata "VM name" "VBoxInternal/Devices/e1000/0/PCIDeviceNo" 8
and as long as you use the PCI device number of a non-existing device of the same type, it would probably work. But going further than that, the problems will start. For example, if you'd change the PCI bus number, you'd also have to create this PCI bus beforehand ... and at some point, you'd probably have to change the VirtualBox implementation yourself ...
EasyRider
Posts: 3
Joined: 17. Mar 2021, 14:54

Re: Predictable network naming, configure enp**-naming?

Post by EasyRider »

fth0 wrote:...
Thank you! This is a couple of steps towards my goal!
About the pci-bus numbering. I had to try to change this and as you said, it would crash. Trying to find anything about pci-bus in the vbox-file but cannot find anything. Is it possible to add extra pci-busses and if so, how?

Thank you!
fth0
Volunteer
Posts: 5668
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: Predictable network naming, configure enp**-naming?

Post by fth0 »

EasyRider wrote:About the pci-bus numbering. I had to try to change this and as you said, it would crash. Trying to find anything about pci-bus in the vbox-file but cannot find anything. Is it possible to add extra pci-busses and if so, how?
I don't know if there is any provision for that. You'd probably have to read, understand, change and build the VirtualBox source code yourself.
Post Reply