Network Interface order with Proxmox

When you create a Proxmox virtual machine (KVM), the network interfaces may not always be in the order you want them to be.

The order of the network interfaces is not only defined by an order in Proxmox. It is also affected by the way the guest OS detects and uses them. In this article I used Proxmox 1.7 with Debian as the guest OS.

The order you create the interfaces in the Proxmox web front-end does not influence the order as it is detected by the guest OS, also the order in the configuration file does not influence it.

Install with one network interface

If you have the possibility to do so, the easiest possible solution would be to install the guest OS with only the network interface you want to have as eth0. If it only has one network interface, the guest OS does not have any option other than to name it eth0. As soon as you have finished the OS installation, you can useĀ udev to make sure the device will keep its name as eth0. This is done by the following configuration line in udev’s rules files. Depending on your distribution you might already have a file for your configuration, if not, just create one and name it similar to this:

$ vim /etc/udev/rules.d/70-persistent-net.rules
KERNEL=="eth*", ATTR{address}=="00:aa:11:bb:22:cc", NAME="eth0"

With the udev configuration in place you can add as many interfaces to the VM (virtual machine) as you need.

Installing with two network interfaces

If you need more then one NIC (Network Interface Card) and want to make sure they are in the right order, the only option I found is choosing different NIC types. I’ve seen that a NIC of type “rtl8139” was detected earlier then a NIC with type “virtio”. So eth0 can be configured via the Proxmox web-interface as “rtl8139” and the interface you want as eth1 as “virtio”. Make sure you stop and then start the VM to apply the changes as a “reset” will not be enough.

infoIf you need more then 2 interfaces during the installation process, take a Live CD of your distribution and create interfaces with more different types and boot the system into the live CD. In the console run “ip addr” and check the order of the interfaces detected with the MAC address against your configuration to see the order they get detected.

As soon as you have installed your operating system, make sure you have the udev configuration in place. This will ensure that the naming of the interfaces will not change.

Now note the VMID, shut down the VM and connect to Proxmox via ssh (Sadly the changes to be done now can not be done via the web-interface). We need to edit the VM’s configuration file. The KVM virtualisation is implemented by a project called “qemu”. The configuration files for the virtual machines are located at “/etc/qemu-server/.conf”. Open the file with the VMID you noted earlier and find the lines with the network interfaces:

$ vim /etc/qemu-server/101.conf

Change the NIC type

You should find lines representing the NIC’s of this VM and their MAC addresses. Choose the NIC type you want to have for both and change it in the configuration file. The resulting lines should look like this, where I have decided to use “virtio”.

vlan1: virtio=7A:A5:1A:45:1A:F3
vlan2: virtio=28:3B:51:9E:AC:68

Now stop and start the VM again to apply the changes. The 2 NIC’s are now of the same type and should still be in the right order. Check this by comparing the MAC addresses before you continue configuring your server.


Read more of my posts on my blog at http://blog.tinned-software.net/.

This entry was posted in Linux Administration, Virtualisation and tagged , , , . Bookmark the permalink.