forked from Mirror/pve-network
sdn: dhcp: request both IPv4 and IPv6 addresses on VM start
If previously an IP was allocated in the IPAM, but a new subnet added for the other IP version, we need to allocate an IP in the new subnet. Signed-off-by: Stefan Lendl <s.lendl@proxmox.com> Reviewed-by: Stefan Hanreich <s.hanreich@proxmox.com> Tested-by: Stefan Hanreich <s.hanreich@proxmox.com>
This commit is contained in:
parent
e06301af3a
commit
5fd3da139b
|
@ -196,12 +196,10 @@ sub add_dhcp_mapping {
|
|||
return if !$zone->{ipam} || !$zone->{dhcp};
|
||||
|
||||
my ($ip4, $ip6) = PVE::Network::SDN::Vnets::get_ips_from_mac($vnetid, $mac);
|
||||
if ( ! ($ip4 || $ip6) ) {
|
||||
print "No IP found for MAC: $mac for VMID:$vmid\n";
|
||||
add_next_free_cidr($vnetid, $name, $mac, "$vmid", undef, 1);
|
||||
add_next_free_cidr($vnetid, $name, $mac, "$vmid", undef, 1, 4) if ! $ip4;
|
||||
add_next_free_cidr($vnetid, $name, $mac, "$vmid", undef, 1, 6) if ! $ip6;
|
||||
|
||||
($ip4, $ip6) = PVE::Network::SDN::Vnets::get_ips_from_mac($vnetid, $mac);
|
||||
print "got new IP from IPAM: $ip4 $ip6\n";
|
||||
}
|
||||
PVE::Network::SDN::Dhcp::add_mapping($vnetid, $mac, $ip4, $ip6) if $ip4 || $ip6;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue