Inconsistent NIC and IP Configuration Order in VMSS

Udayakumar Iyappan 20 Reputation points
2025-01-30T06:04:12.9633333+00:00

I have created a Virtual Machine Scale Set (VMSS) with multiple NICs and IP configurations. The initial configuration was as follows:

  • NIC0: Subnet 21.0.16.0/24
  • NIC1: Subnet 21.0.32.0/24
  • NIC2: Subnet 21.0.48.0/24
  • NIC3: Subnet 21.0.64.0/24

When the VMSS was created with a VM count of 1, the NICs were assigned correctly (eth0: 21.0.16.0, eth1: 21.0.32.0, eth2: 21.0.48.0, eth3: 21.0.64.0). However, after scaling the VMSS to 10 instances, some VMs have inconsistent NIC and IP configuration orders. For example:

  • eth0: 21.0.16.0
  • eth1: 21.0.48.0
  • eth2: 21.0.64.0
  • eth3: 21.0.32.0

This inconsistency is causing issues with our application, which relies on a specific NIC order. Please investigate and guide how to enforce consistent NIC and IP configuration ordering in VMSS.

Azure Virtual Machine Scale Sets
Azure Virtual Machine Scale Sets
Azure compute resources that are used to create and manage groups of heterogeneous load-balanced virtual machines.
425 questions
{count} votes

Accepted answer
  1. Zafer KAYA 95 Reputation points MVP
    2025-01-30T06:38:07.4466667+00:00

    While Azure does not natively guarantee a consistent NIC order when scaling VMSS, you can configure the scale set so that each VM in the set uses the same NICs. Here’s how to achieve this:

    Assign NICs during VMSS creation: When configuring a VMSS, ensure that the NICs are explicitly associated with each VM instance at the time of scale set creation. This can be done via the VMSS configuration using Azure Resource Manager (ARM) templates or Terraform.

    Use the --nics flag when defining VMSS to ensure that NICs are attached in a consistent order.

    If the VMSS instances are already scaled out, you may need to reconfigure the NICs.

    You may consider manually managing the NIC configurations after scaling. Here's the process:

    • Detach and reattach the NICs to the VMSS instances in the desired order via the Azure portal or using PowerShell/CLI commands.
    • This is not an ideal solution for long-term management since it involves manual intervention, but it can help restore order when scaling issues arise.
    • You can use a custom script extension that runs on VMSS instance boot to configure the NICs in the desired order. This script could:
    • Use ifconfig or ip commands to set the correct network configuration for each NIC.
    • Alternatively, the script could assign static IPs or set routing rules to ensure that each NIC is used for the correct traffic.
    • az vmss extension set \ --resource-group <resource-group-name> \ --vmss-name <vmss-name> \ --name customScript \ --script-file <script-path> \ --version 2.0 If your application needs to identify NICs consistently, you could assign a static DNS name to each NIC. Using DNS names (or even a custom hostname configuration) allows your application to reference NICs in a predictable way, regardless of their order in the interface list.
      • You can define a custom hostname for each instance in your VMSS using the Azure custom script extension. The hostname can be assigned dynamically based on NIC order.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. SUNOJ KUMAR YELURU 14,981 Reputation points MVP
    2025-01-30T06:52:17.8966667+00:00

    Hello @Udayakumar Iyappan

    Thanks for using Q & A forum

    The inconsistent NIC and IP configuration ordering in the Azure VMSS after scaling is due to the platform's dynamic IP assignment and the lack of explicit ordering constraints during VMSS creation. Enforcing consistent ordering requires leveraging Azure's network interface capabilities and potentially custom scripts for post-deployment configuration.

    1. Dynamic IP Assignment: Azure VMSS, by default, assigns IP addresses dynamically. While the initial VM might have a predictable order, scaling introduces variability as the platform allocates available IPs across different subnets. This inherent dynamism leads to the observed inconsistencies.
    2. Lack of Explicit NIC Ordering: The Azure portal and ARM templates don't inherently provide a mechanism to explicitly define the order of NICs attached to a VM within a VMSS. The order is not guaranteed to be preserved across all instances after scaling.
    3. Network Interface Configuration: The network interface configuration, while defined during VMSS creation, is not strictly enforced in the order specified during scaling. Azure's resource allocation process prioritizes availability and efficiency, potentially leading to variations in the interface order.

    Alternative Viewpoints

    1. Using a Custom Script Extension: A post-deployment script extension could be used to reorder the interfaces based on IP address or other identifying characteristics. This would require careful scripting and testing to ensure reliability across all instances.

    If the Answer is helpful, please click Accept Answer and Up-Vote, so that it can help others in the community looking for help on similar topics.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.