Use a map to store allocated IPs and try to allocate new IP if possible