diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index 7c9b51b6c92..57d58ce72e5 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -519,7 +519,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag Long vlanId = null; List maps = _accountVlanMapDao.listAccountVlanMapsByAccount(ownerId); if (maps != null && !maps.isEmpty()) { - vlanId = maps.get(0).getVlanDbId(); + //check if the ips from this vlan are associated with this network + List ips = _ipAddressDao.listByVlanId(maps.get(0).getVlanDbId()); + if (ips != null && !ips.isEmpty() && ips.get(0).getAssociatedWithNetworkId() == network.getId()) { + vlanId = maps.get(0).getVlanDbId(); + } } ip = fetchNewPublicIp(dcId, null, vlanId, owner, VlanType.VirtualNetwork, network.getId(), true, false, null, false);