]> git.proxmox.com Git - pve-container.git/blobdiff - src/PVE/API2/LXC.pm
clone: randomize network MAC HW address of clone
[pve-container.git] / src / PVE / API2 / LXC.pm
index 0c9ee40c7834369b902dd4fe03d8ebe533b69531..0c834d41fbb3262a87be78bca7105ae267bd25ef 100644 (file)
@@ -1350,6 +1350,12 @@ __PACKAGE__->register_method({
                            # TODO: allow bind mounts?
                            die "unable to clone mountpint '$opt' (type $mp->{type})\n";
                        }
+                   } elsif ($opt =~ m/^net(\d+)$/) {
+                       # always change MAC! address
+                       my $dc = PVE::Cluster::cfs_read_file('datacenter.cfg');
+                       my $net = PVE::LXC::Config->parse_lxc_network($value);
+                       $net->{hwaddr} = PVE::Tools::random_ether_addr($dc->{mac_prefix});
+                       $newconf->{$opt} = PVE::LXC::Config->print_lxc_network($net);
                    } else {
                        # copy everything else
                        $newconf->{$opt} = $value;