在覆盖网络上,NSX-T Data Center 支持路由 L3 域上的 VLAN 间流量。在路由过程中,虚拟分布式路由器 (Virtual Distributed Router, VDR) 使用 VLAN ID 在 VLAN 子网之间路由数据包。

VLAN 间路由消除了每个虚拟机只能使用 10 个 vNIC 的限制。支持 VLAN 间路由的 NSX-T Data Center 可确保能够在 vNIC 上创建多个 VLAN 子接口并将其用于不同的网络连接服务。例如,虚拟机的一个 vNIC 可以分为多个子接口。每个子接口都属于一个子网,可以托管一个网络连接服务,如 SNMP 或 DHCP。例如,使用 VLAN 间路由时,VLAN-10 上的子接口可以访问 VLAN-10 或任何其他 VLAN 上的子接口。

虚拟机上的每个 vNIC 均通过父逻辑端口连接到 N-VDS,从而管理未标记的数据包。

要创建子接口,请在增强型 N-VDS 交换机上,使用此过程中所述的 API 调用,创建一个使用具有关联 VIF 的 API 的子端口。使用 VLAN ID 标记的子接口将关联到新的逻辑交换机,例如,VLAN10 将连接到逻辑交换机 LS-VLAN-10。必须将 VLAN10 的所有子接口连接到 LS-VLAN-10。子接口的 VLAN ID 与其关联的逻辑交换机之间的这种一对一映射是一项重要的必备条件。例如,如果将具有 VLAN20 的子端口添加到映射到 VLAN-10 的逻辑交换机 LS-VLAN-10,则会导致 VLAN 之间的数据包路由无法正常工作。此类配置错误会导致 VLAN 间路由无法正常工作。

NSX-T Data Center 3.2.2 开始,逻辑端口 proton API 将替换为相应的分段端口策略 API。

前提条件

  • 在将 VLAN 子接口关联到逻辑交换机之前,请确保逻辑交换机未与其他 VLAN 子接口相关联。如果存在不匹配的情况,VLAN 间路由可能无法在覆盖网络上正常运行。

  • 确保主机运行 ESXi v 6.7 U2 或更高版本。

过程

  1. 要为 vNIC 创建子接口,请确保将该 vNIC 更新为父端口。进行以下 REST API 调用:
    PATCH https://<nsx-mgr-ip>/policy/api/v1/infra/segments/<Segment to which vNIC is connected>/ports/<Seg-Port-vNIC>
    {
       "attachment": {
         "id": "<Attachment UUID of the vNIC>",
         "type": "PARENT"
      },
       "admin_state": "UP",
       "resource_type": "SegmentPort",
       "display_name": "parentport"
    }
    }
    如果逻辑交换机没有相应的分段,您可以进行以下 REST API 调用(逻辑端口 proton API):
    PUT https://<nsx-mgr-ip>/api/v1/logical-ports/<Logical-Port UUID-of-the-vNIC>
    {
      "resource_type" : "LogicalPort",
      "display_name" : "parentport",
      "attachment" : {
        "attachment_type" : "VIF",
        "context" : {
          "resource_type" : "VifAttachmentContext",
          "vif_type": "PARENT"
        },
        "id" : "<Attachment UUID of the vNIC>"   
      },
      "admin_state" : "UP",
      "logical_switch_id" : "UUID of Logical Switch to which the vNIC is connected",  
      "_revision" : 0
    }
  2. 要为与虚拟机上的子接口关联的 N-VDS 上的父 vNIC 端口创建子端口,请进行以下 API 调用:
    注: 在进行 API 调用之前,请确认存在分段,以便将子端口连接到虚拟机上的子接口。
    PUT https://<nsx-mgr-ip>/policy/api/v1/infra/segments/<Segment to which child port is connected>/ports/<Child-port>
    {
       "attachment": {
         "id": "<Attachment UUID of the CHILD port>",
         "type": "CHILD",
         "context_id": "<Attachment UUID of the PARENT port from Step 1>",
         "traffic_tag": <VLAN ID>,
         "app_id": "<ID of the attachment>", ==> display id(can be any string). Must be unique.
      },
       "address_bindings": [
        {
           "ip_address": "<IP address to the corresponding VLAN>",
           "mac_address": "<vNIC MAC Address>",
           "vlan_id": <VLAN ID>
        }
      ],
       "admin_state": "UP",
       "resource_type": "SegmentPort",
       "display_name": "<Name of the Child PORT>"
    }
    
    如果逻辑交换机没有相应的分段,您可以进行以下 REST API 调用(逻辑端口 proton API):
    POST https://<nsx-mgr-ip>/api/v1/logical-ports/
    {
      "resource_type" : "LogicalPort",
      "display_name" : "<Name of the Child PORT>",   
      "attachment" : {
        "attachment_type" : "VIF",
        "context" : {
          "resource_type" : "VifAttachmentContext",
          "parent_vif_id" : "<UUID of the PARENT port from Step 1>",     
          "traffic_tag" : <VLAN ID>,    
          "app_id" : "<ID of the attachment>",  ==> display id(can give any string). Must be unique.
          "vif_type" : "CHILD"
        },
       "id" : "<ID of the CHILD port>"  
      },
      
      "logical_switch_id" : "<UUID of the Logical switch(not the PARENT PORT's logical switch) to which Child port would be connected to>",         
      "address_bindings" : [ { "mac_address" : "<vNIC MAC address>", "ip_address" : "<IP address to the corresponding VLAN>", "vlan" : <VLAN ID> } ],       
      "admin_state" : "UP"
    }

结果

NSX-T Data Center 将在虚拟机上创建子接口。