Set network interface name in VM

MikeAndreev

Member
Feb 3, 2021
12
1
8
54
Hallo!
I test migration from Ovirt to Proxmox with keep existing VM rbd images on CEPH storages.
Problem: In oVirt all Centos VM have type of Netcard "VirtIO" - same as I set in Proxmox, but in oVirt it use default name for interface "ens3" but in Proxmox VM got name "ens18"
So network is down, of course, after start VM in Proxmox. I understand that I can rename the interface manually, but we have more than 200 VMs for migration :(((((((((
Is there any way to set a name for the VM interface?
 
The difference is because proxmox assign virtio nic on differents virtual pci slots. (ens18 = pci slot 18)

one way is to disable ensX naming, and use classic ethX (grub option net.ifnames=0)

or you can do an udev rules, to rename interface name from the mac address.

or you can use systemd link
https://wiki.debian.org/NetworkInterfaceNames
 
spirit, thanks for fast and detail answered ! , but the problem we don't have root(or console with sudo) access to many VMs, so we need tell VM owners how to change the adapter name or run a some script to change it...
is it possible change PCI number of Net-card on "virtual hardware" level?
 
OK, I found a way to solve this problem: usage "args:" in qm.conf and add line with params for "ens3" Net-card:

args: -netdev type=tap,id=net0,ifname=tap100i0,script=/var/lib/qemu-server/pve-bridge,downscript=/var/lib/qemu-server/pve-bridgedown,vhost=on -device virtio-net-pci,mac=86:87:7D:4F:CB:40,netdev=net0,bus=pci.0,addr=03.0,id=net0

also I comment out original parameters

#net0: virtio=86:87:7D:4F:CB:40,bridge=vmbr10,firewall=1,tag=140

but when I start VM I got error 65280:

# qm start 100
unable to get network config 'net0'
kvm: network script /var/lib/qemu-server/pve-bridge failed with status 65280
start failed: QEMU exited with code 1

Any ideas?
 
spirit, thanks for fast and detail answered ! , but the problem we don't have root(or console with sudo) access to many VMs, so we need tell VM owners how to change the adapter name or run a some script to change it...
is it possible change PCI number of Net-card on "virtual hardware" level?
oh ok ,I'll be difficult because it's hardcoded in proxmox code

/usr/share/perl5/PVE/QemuServer/PCI.pm
Code:
sub get_pci_addr_map {

     net0 => { bus => 0, addr => 18 },
        net1 => { bus => 0, addr => 19 },
        net2 => { bus => 0, addr => 20 },
        net3 => { bus => 0, addr => 21 },
        net4 => { bus => 0, addr => 22 },
        net5 => { bus => 0, addr => 23 },
        vga1 => { bus => 0, addr => 24 },
        vga2 => { bus => 0, addr => 25 },
        vga3 => { bus => 0, addr => 26 },

you could hack this, but need to change it each time you upgrade proxmox qemu-server package
 
OK, I found a way to solve this problem: usage "args:" in qm.conf and add line with params for "ens3" Net-card:

args: -netdev type=tap,id=net0,ifname=tap100i0,script=/var/lib/qemu-server/pve-bridge,downscript=/var/lib/qemu-server/pve-bridgedown,vhost=on -device virtio-net-pci,mac=86:87:7D:4F:CB:40,netdev=net0,bus=pci.0,addr=03.0,id=net0

also I comment out original parameters

#net0: virtio=86:87:7D:4F:CB:40,bridge=vmbr10,firewall=1,tag=140

but when I start VM I got error 65280:

# qm start 100
unable to get network config 'net0'
kvm: network script /var/lib/qemu-server/pve-bridge failed with status 65280
start failed: QEMU exited with code 1

Any ideas?
It's no so simple, because proxmox need to plug tap interface in the bridge with pve-bridge, and if don't define net0, it'll not works
 
  • Like
Reactions: wszelaki

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!