你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

通过 PowerShell 在 Azure Stack Edge Pro GPU 中创建新的虚拟交换机

适用于:Yes for Pro GPU SKUAzure Stack Edge Pro - GPUYes for Pro 2 SKUAzure Stack Edge Pro 2Yes for Pro R SKUAzure Stack Edge Pro RYes for Mini R SKUAzure Stack Edge Mini R

本文介绍如何在 Azure Stack Edge Pro GPU 设备上创建新的虚拟交换机。 例如,如果希望虚拟机通过其他物理网络端口进行连接,则需创建新的虚拟交换机。 有关详细信息,请参阅使用 Azure 门户管理 Azure Stack Edge Pro GPU 上 VM 上的网络接口

VM 部署工作流

  1. 连接到设备上的 PowerShell 接口。
  2. 查询可用的物理网络接口。
  3. 创建虚拟交换机。
  4. 验证自动创建的虚拟网络和子网。

先决条件

在开始之前,请确保:

连接到 PowerShell 接口

连接到设备的 PowerShell 界面

查询可用网络接口

  1. 使用以下命令显示可创建新虚拟交换机的物理网络接口的列表。 你将选择其中一个网络接口。

    Get-NetAdapter -Physical
    

    下面是示例输出:

        [10.100.10.10]: PS>Get-NetAdapter -Physical
    
        Name                      InterfaceDescription                    ifIndex Status       MacAddress       LinkSpeed
        ----                      --------------------                    ------- ------       ----------        -----
        Port2                     QLogic 2x1GE+2x25GE QL41234HMCU NIC ...      12 Up           34-80-0D-05-26-EA ...ps
        Ethernet                  Remote NDIS Compatible Device                11 Up           F4-02-70-CD-41-39 ...ps
        Port1                     QLogic 2x1GE+2x25GE QL41234HMCU NI...#3       9 Up           34-80-0D-05-26-EB ...ps
        Port5                     Mellanox ConnectX-4 Lx Ethernet Ad...#2       8 Up           0C-42-A1-C0-E3-99 ...ps
        Port3                     QLogic 2x1GE+2x25GE QL41234HMCU NI...#4       7 Up           34-80-0D-05-26-E9 ...ps
        Port6                     Mellanox ConnectX-4 Lx Ethernet Adapter       6 Up           0C-42-A1-C0-E3-98 ...ps
        Port4                     QLogic 2x1GE+2x25GE QL41234HMCU NI...#2       4 Up           34-80-0D-05-26-E8 ...ps
    
        [10.100.10.10]: PS>
    
  2. 选择一个网络接口,该接口:

    • 处于“启动”状态。
    • 未用于任何现有虚拟交换机。 目前只能为每个网络接口配置一个虚拟交换机。

    若要检查现有虚拟交换机和网络接口关联,请运行 Get-HcsExternalVirtualSwitch 命令。

    下面是示例输出。

    [10.100.10.10]: PS>Get-HcsExternalVirtualSwitch
    
    Name                          : vSwitch1
    InterfaceAlias                : {Port2}
    EnableIov                     : True
    MacAddressPools               :
    IPAddressPools                : {}
    ConfigurationSource           : Dsc
    EnabledForCompute             : True
    SupportsAcceleratedNetworking : False
    DbeDhcpHostVnicName           : f4a92de8-26ed-4597-a141-cb233c2ba0aa
    Type                          : External
    
    [10.100.10.10]: PS>
    

    在此实例中,端口 2 与现有虚拟交换机相关联,不应被使用。

创建虚拟交换机

使用以下 cmdlet 在指定的网络接口上创建新的虚拟交换机。 完成此操作后,计算实例可以使用新的虚拟网络。

Add-HcsExternalVirtualSwitch -InterfaceAlias <Network interface name> -WaitForSwitchCreation $true

使用 Get-HcsExternalVirtualSwitch 命令识别新建的交换机。 创建的新交换机名称为 vswitch-<InterfaceAlias>

下面是示例输出:

[1HXG613.microsoftdatabox.com]: PS>Get-HcsExternalVirtualSwitch

Name                          : vSwitch1
InterfaceAlias                : {Port2}
EnableIov                     : True
MacAddressPools               : {}
IPAddressPools                : {Name: 'KubernetesNodeIPs', AddressRange: '10.126.75.200-10.126.75.202', Name:
                                'KubernetesServiceIPs', AddressRange: '10.126.75.206-10.126.75.208'}
BGPPeers                      : {}
ConfigurationSource           : ClusterNetwork
EnabledForCompute             : True
EnabledForStorage             : False
EnabledForMgmt                : True
SupportsAcceleratedNetworking : False
DbeDhcpHostVnicName           : bc29af45-88b7-43af-ab27-78cc6427bc5f
VirtualNetworks               : {}
EnableEmbeddedTeaming         : True
InternalVnetName              :
Type                          : External
Mtu                           : 1500

Name                          : vSwitch2
InterfaceAlias                : {Port3, Port4}
EnableIov                     : True
MacAddressPools               : {}
IPAddressPools                : {}
BGPPeers                      : {}
ConfigurationSource           : ClusterNetwork
EnabledForCompute             : False
EnabledForStorage             : True
EnabledForMgmt                : False
SupportsAcceleratedNetworking : False
DbeDhcpHostVnicName           : 25c6bdc4-2991-41db-8757-1fb08a219ea7
VirtualNetworks               : {}
EnableEmbeddedTeaming         : True
InternalVnetName              :
Type                          : External
Mtu                           : 1500

Name                          : TestvSwitch
InterfaceAlias                : {Port5}
EnableIov                     : True
MacAddressPools               : {}
IPAddressPools                : {}
BGPPeers                      : {}
ConfigurationSource           : User
EnabledForCompute             : False
EnabledForStorage             : False
EnabledForMgmt                : False
SupportsAcceleratedNetworking : True
DbeDhcpHostVnicName           : ed7eb61d-7dd8-4648-bb8e-04fe5b0b6fd6
VirtualNetworks               : {Name: 'TestvSwitch-internal', AddressSpace: '192.0.2.0/24', SwitchName:
                                'TestvSwitch', GatewayIPAddress: '192.0.2.0/24', DnsServers: '192.0.2.0/24', VlanId:
                                '0'EnabledForK8s: FalseIPAddressPools:    VirtualMachineIPs , 192.0.2.0/24}
EnableEmbeddedTeaming         : False
InternalVnetName              : TestvSwitch-internal
Type                          : External
Mtu                           : 9000

[1HXG613.microsoftdatabox.com]: PS>

验证交换机的网络和子网

创建新的虚拟交换机后,Azure Stack Edge Pro GPU 会自动创建对应的虚拟网络和子网。 创建 VM 时,可以使用此虚拟网络。

若要标识与创建的新交换机关联的虚拟网络和子网,请使用 Get-HcsVirtualNetwork cmdlet。

创建虚拟 LAN

若要在虚拟交换机上添加局域网 (LAN) 配置,请使用以下 cmdlet。

Add-HcsVirtualNetwork-VirtualSwitchName <Virtual Switch name> -Name <Virtual Network Name> –VlanId <Vlan Id> –AddressSpace <Address Space> –GatewayIPAddress <Gateway IP>–DnsServers <Dns Servers List> -DnsSuffix <Dns Suffix name>

以下参数可以与 Add-HcsVirtualNetwork-VirtualSwitchName cmdlet 一起使用。

参数 说明
Name 虚拟 LAN 网络名称
VirtualSwitchName 要添加虚拟 LAN 配置的虚拟交换机名称
AddressSpace 虚拟 LAN 网络的子网地址空间
GatewayIPAddress 虚拟网络网关
DnsServers DNS 服务器 IP 地址列表
DnsSuffix 没有虚拟 LAN 网络子网主机部分的 DNS 名称
VlanId 如果需要未标记的网络,可以将 VlanId 设置为 0。 如果支持标记的配置或中继配置,请在范围 1-4094 中指定 VlanID。

下面是示例输出。

PS C:\> Add-HcsVirtualNetwork -VirtualSwitchName vSwitch1 -Name vlanNetwork100 -VlanId 100 -AddressSpace 5.5.0.0/16 -GatewayIPAddress 5.5.0.1 -DnsServers "5.5.50.50,5.5.50.100" -DnsSuffix "name.domain.com"
PS C:\> Get-HcsVirtualNetwork 
Name             : vlanNetwork100
AddressSpace     : 5.5.0.0/16
SwitchName       : vSwitch1
GatewayIPAddress : 5.5.0.1
DnsServers       : {5.5.50.50, 5.5.50.100}
DnsSuffix        : name.domain.com
VlanId           : 100
MacAddressPools  :
IPAddressPools   : {}
BGPPeers         :
EnabledForK8s    : False

注意

  • 可以在同一虚拟交换机上配置多个虚拟 LAN。
  • 网关 IP 地址必须与作为地址空间传入的参数在同一子网中。
  • 如果配置了虚拟 LAN,则不能删除虚拟交换机。 若要删除此虚拟交换机,首先需要删除虚拟 LAN,然后删除虚拟交换机。

验证虚拟 LAN 的网络和子网

创建虚拟 LAN 后,会自动创建虚拟网络和相应的子网。 创建 VM 时,可以使用此虚拟网络。

若要标识与创建的新交换机关联的虚拟网络和子网,请使用 Get-HcsVirtualNetwork cmdlet。

后续步骤