Azure IoT Edge for Linux on Windows virtual multiple NIC configurations

Applies to: IoT Edge 1.4 checkmark IoT Edge 1.4

By default, the Azure IoT Edge for Linux on Windows (EFLOW) virtual machine has a single network interface card (NIC) assigned. However, you can configure the EFLOW VM with multiple network interfaces by using the EFLOW support for attaching multiple network interfaces to the virtual machine. This functionality may be helpful in numerous scenarios where you may have a networking division or separation into different networks or zones. In order to connect the EFLOW virtual machine to the different networks, you may need to attach different network interface cards to the EFLOW virtual machine.

This article describes how to configure the Azure IoT Edge for Linux on Windows VM to support multiple NICs and connect to multiple networks. This process is divided into the following steps:

  • Create and assign a virtual switch
  • Create and assign a network endpoint
  • Check the VM network configurations

For more information about networking concepts and configurations, see Azure IoT Edge for Linux on Windows Networking and How to configure Azure IoT Edge for Linux on Windows networking.

Prerequisites

Create and assign a virtual switch

During the EFLOW VM deployment, the VM had a switched assigned for all the communications between the Windows host OS and the virtual machine. This will always be the switch used for VM lifecycle management communications, and it's not possible to delete it.

The following steps in this section show how to assign a network interface to the EFLOW virtual machine. Ensure that the virtual switch being used and the networking configuration aligns with your networking environment. For more information about networking concepts like type of switches, DHCP and DNS, see Azure IoT Edge for Linux on Windows networking.

  1. Open an elevated PowerShell session by starting with Run as Administrator.

  2. Check the virtual switch to be assigned to the EFLOW VM is available.

    Get-VMSwitch -Name "{switchName}" -SwitchType {switchType}
    
  3. Assign the virtual switch to the EFLOW VM.

    Add-EflowNetwork -vSwitchName "{switchName}" -vSwitchType {switchType}
    

    For example, if you wanted to assign the external virtual switch named OnlineExt, you should use the following command

    Add-EflowNetwork -vSwitchName "OnlineExt" -vSwitchType "External"
    

    EFLOW attach virtual switch

  4. Check that the virtual switch was correctly assigned to the EFLOW VM.

    Get-EflowNetwork -vSwitchName "{switchName}"
    

For more information about attaching a virtual switch to the EFLOW VM, see PowerShell functions for Azure IoT Edge for Linux on Windows.

Create and assign a network endpoint

Once the virtual switch was successfully assigned to the EFLOW VM, you need to create a networking endpoint assigned to virtual switch to finalize the network interface creation. If you're using Static IP, ensure to use the appropriate parameters: ip4Address, ip4GatewayAddress and ip4PrefixLength.

  1. Open an elevated PowerShell session by starting with Run as Administrator.

  2. Create the EFLOW VM network endpoint

    • If you're using DHCP, no Static IP parameters are needed.

      Add-EflowVmEndpoint -vSwitchName "{switchName}" -vEndpointName "{EndpointName}"
      
    • If you're using Static IP

      Add-EflowVmEndpoint -vSwitchName "{switchName}" -vEndpointName "{EndpointName}" -ip4Address "{staticIp4Address}" -ip4GatewayAddress "{gatewayIp4Address}" -ip4PrefixLength "{prefixLength}"
      

      For example, if you wanted to create and assign the OnlineEndpoint endpoint with the external virtual switch named OnlineExt, and Static IP configurations (ip4Address=192.168.0.103, ip4GatewayAddress=192.168.0.1, ip4PrefixLenght=24) you should use the following command:

      Add-EflowVmEndpoint -vSwitchName "OnlineExt" -vEndpointName "OnlineEndpoint" -ip4Address "192.168.0.103" -ip4GatewayAddress "192.168.0.1" -ip4PrefixLength "24"
      

      EFLOW attach network endpoint

  3. Check that the network endpoint was correctly created and assigned to the EFLOW VM. You should see the two network interfaces assigned to the virtual machine.

    Get-EflowVmEndpoint
    

    EFLOW get attached network interfaces

For more information about creating and attaching a network endpoint to the EFLOW VM, see PowerShell functions for Azure IoT Edge for Linux on Windows.

Check the VM network configurations

The final step is to make sure the networking configurations were applied correctly and the EFLOW VM has the new network interface configured. The new interface will show up as "eth1" if it's the first extra interface added to the VM.

  1. Open PowerShell in an elevated session. You can do so by opening the Start pane on Windows and typing in "PowerShell". Right-click the Windows PowerShell app that shows up and select Run as administrator.

  2. Connect to the EFLOW VM.

    Connect-EflowVm
    
  3. Once inside the VM, check the network interfaces and their configurations using the ifconfig command.

    ifconfig
    

    The default interface eth0 is the one used for all the VM management. You should see another interface, like eth1, which is the new interface that was assigned to the VM. Following the examples above, if you previously assigned a new endpoint with the static IP 192.168.0.103 you should see the interface eth1 with the inet addr: 192.168.0.103.

    EFLOW VM network interfaces

Next steps

Follow the steps in How to configure networking for Azure IoT Edge for Linux on Windows to make sure all the networking configurations were applied correctly.