udev eth association with Proxmox

If you are here, you may have the same problem as I encountered. The way you create net card in Proxmox, is not predictable in linux. If you have seen my article about simple-cdd, you may better understand why we solved this way.

udev works with address

Yes. It is. But it works with regular expressions, so we can use for our goal. How? Check this base.postinst file portion:

echo '  
KERNEL=="eth*", ATTR{address}=="*:db:00", NAME="eth0"  
KERNEL=="eth*", ATTR{address}=="*:db:01", NAME="eth1"  
KERNEL=="eth*", ATTR{address}=="*:db:02", NAME="eth2"  
KERNEL=="eth*", ATTR{address}=="*:db:03", NAME="eth3"  
KERNEL=="eth*", ATTR{address}=="*:db:04", NAME="eth4"  
KERNEL=="eth*", ATTR{address}=="*:db:05", NAME="eth5"  
KERNEL=="eth*", ATTR{address}=="*:db:06", NAME="eth6"  
KERNEL=="eth*", ATTR{address}=="*:db:07", NAME="eth7"  
KERNEL=="eth*", ATTR{address}=="*:db:08", NAME="eth8"  
KERNEL=="eth*", ATTR{address}=="*:db:09", NAME="eth9"  
' > /etc/udev/rules.d/70-persistent-net.rules

Preseeding all your VM this way let you have the eth named as you want in linux. Let's see how.

  • create a VM in proxmox
  • before starting, edit the eth mac address changing only the last two pairs of chars, with, for example, :db:04 for having an eth4 in linux.
  • start the VM
  • check with ifconfig the naming

This solution works good and it is very simple to implement.