From: Thomas Lamprecht Date: Tue, 20 Mar 2018 14:28:46 +0000 (+0100) Subject: clone: randomize network MAC HW address of clone X-Git-Url: https://git.proxmox.com/?p=pve-container.git;a=commitdiff_plain;h=63231f52d61e3f6a38b9ed0e760baae907a77516 clone: randomize network MAC HW address of clone adapt code from qemu-servers clone API path and generate a new randomized network hardware address (MAC) for the new clone to avoid address collisions Signed-off-by: Thomas Lamprecht --- diff --git a/src/PVE/API2/LXC.pm b/src/PVE/API2/LXC.pm index 0c9ee40..0c834d4 100644 --- a/src/PVE/API2/LXC.pm +++ b/src/PVE/API2/LXC.pm @@ -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;