MAC prefix for each vnet

ns33

Member
Apr 4, 2024
36
3
8
Is it possible to have a mac address prefix for each vnet?

I know there's a global prefix setting under Datacenter but nothing for vnets. Anyway to do this via the cli?
 
Not that I know of, maybe room for a contribution here.. However, technically, the MAC is linked to the VM/CT, not to the network it's hooked on, so that may not be a reasonable feature. Imagine a NIC whose MAC would change depending on the switch it's plugged in, I'd be unhappy :P
 
I'm confused, why would it ever change past the creation? Once set, how often is it reconfigured anyway? Its prefix would only apply during creation, just like the current datacenter wide prefix applies. Changing the bridge in an adapter doesn't currently regenerate the mac, even if you change the datacenter level prefix; I wouldn't expect that workflow to change. It's just an on-creation feature.

It would be a huge benefit for anything that is auto deployed and the mac of the network defines the network config.

A contribution would be easy in theory. I'm assuming the sdn is written in Rust which I'm just scratching the surface. Correction looks like Perl?
 
Last edited:
Well, unless you actually restore a backup, it won't leave the cluster, that's quite a given. But a NIC can easily be replugged to another bridge.. I guess if it's more of a marker, and if you make sure you don't reconfigure the NIC it's fine, but there are many cases where you'd change that.. Creation (or clone) is easy, but you'd need to either say you don't care after, or deal with what would happen if it switches networks!

And yeah, random_ether_addr is written and mostly called (with prefix) in Perl, so you'd need to hack around it, but maybe ask on here, on pve-devel or on the bugtracker if that's something that would be interesting at all, as I'm not sure this is super relevant, but maybe that's just me.
 
Last edited:
setting mac on vnet could be only usefull if you have an ip on the vnet. (so mainly when vnet is used as gateway for the vms).

It's only possible with evpn, as the ip/mac is the same on each vnet (anycast ip). Don't make sense to add feature for other zone type.

if really needed, you can override in /etc/network/interfaces with

Code:
iface vnetxxx
      hwaddress <mac>

I'll be merged with sdn generated config.