Symptoms
免责声明:本文为 Configuring vSwitch or vNetwork Distributed Switch from the command line in ESXi/ESX (1008127) 的翻译版本。尽管我们会不断努力为本文提供最佳翻译版本,但本地化的内容可能会过时。有关最新内容,请参见英文版本。
- 由于上行链路 (vmnic) 已更改或顺序不正确,因此无法通过网络连接 ESXi/ESX 主机
- 主服务控制台/VMkernel 管理接口已从交换机移动到不可路由的网络上的 Distributed Switch
- 管理网络的 VLAN 已更改或在上行链路交换机端口上配置不正确
Purpose
本文介绍通过正确的 vmnic 接口还原管理网络连接的命令和信息。
Resolution
注意:
- 在 ESX 4.0 Update 2 中,提供了一个新的命令行工具 console-setup,用于简化在 ESX 服务控制台中创建或还原网络连接的过程。有关详细信息,请参见 Configuring or restoring networking from the ESX service console using console-setup (1022078)。
- 在 ESXi 4.x、5.x 和 6.x 中,您可以使用直接控制台用户界面 (DCUI) 控制台屏幕中的还原标准交换机选项将网络还原为标准 vSwitch(在控制台中按 F2)。该操作会清空 ESXi 主机上的网络配置(1 个 vSwitch 和 1 个 vmkernel 端口组)。所有的现有 vSwitch、端口组和 VMkernel 信息都会被移除。VMware 建议在使用此选项之前先通过 vSphere Client 对网络配置进行屏幕截图,或者保存 esxcfg-vswitch -l 和 esxcfg-vmknic -l 命令的输出。
在 ESXi 5.x 和 6.x 中
要将管理 vmkernel 接口还原为正确的 vmnic 接口,请执行以下操作:
- 使用以下命令查看当前 vSwitch 配置和 vmkernel 接口配置:
esxcli network vswitch standard list # list current vswitch configuration
esxcli network vswitch dvs vmware list # list Distributed Switch configuration
esxcli network ip interface list # list vmkernel interfaces and their configuration
esxcli network nic list # display listing of physical adapters and their link state
- 使用以下命令在标准 vSwitch 中添加或移除网卡(称为 vmnic):
esxcli network vswitch standard uplink remove --uplink-name=vmnic --vswitch-name=vSwitch # unlink an uplink
esxcli network vswitch standard uplink add --uplink-name=vmnic --vswitch-name=vSwitch # add an uplink
- 使用以下命令在 vNetwork Distributed Switch (vDS) 中添加或移除网卡(称为 vmnic):
esxcfg-vswitch -Q vmnic -V dvPort_ID_of_vmnic dvSwitch # unlink/remove a vDS uplink
esxcfg-vswitch -P vmnic -V unused_dvPort_ID dvSwitch # add a vDS uplink
注意:如果将管理网络连接迁移到 Distributed Switch 时连接断开,则可能需要移除或禁用现有管理 vmkernel 接口,并在标准 vSwitch 端口组中使用相同的 IP 配置重新创建该接口。 - 在 vSphere Distributed Switch (vDS) 上,使用以下命令删除现有 VMkernel 端口:
esxcli network ip interface remove --interface-name=vmkX
注意:运行 esxcli network ip interface list 命令可确定用于管理的 vmk 接口号。移除不可访问的 vmkernel 端口后,可在标准交换机上重新创建该端口。
- 如果不存在现有标准交换机,您可以使用以下命令创建新的标准交换机以及要使用的端口组:
esxcli network vswitch standard add --vswitch-name=vSwitch
esxcli network vswitch standard portgroup add --portgroup-name=portgroup --vswitch-name=vSwitch注意:创建虚拟交换机时,默认情况下不存在链接 vmnic。您需要按照本文前文所述链接 vmnic。
- 要创建 VMkernel 端口并将其附加到标准 vSwitch 上的端口组,请运行以下命令:
esxcli network ip interface add --interface-name=vmkX --portgroup-name=portgroup
esxcli network ip interface ipv4 set --interface-name=vmkX --ipv4=ipaddress --netmask=netmask --type=static
注意:默认情况下,ESXi 管理 vmkernel 端口为 vmk0,并驻留在名为“管理网络”的标准交换机端口组中。
- 如果与管理网络相关联的 vmnic 是 VLAN 中继,则可能需要为管理端口组指定 VLAN ID。要设置或更正标准 vSwitch 上管理连接所需的 VLAN ID,请运行以下命令:
esxcli network vswitch standard portgroup set -p portgroup --vlan-id VLAN
- 如果尽管网络连接的配置正确但网络连接未还原,则可能需要重新启动主机的管理代理:
services.sh restart
在 ESXi 3.x 和 4.x 中
- 使用以下命令查看当前 vSwitch 配置和 vmkernel 接口配置:
esxcfg-vswitch -l # list current vswitch configuration
esxcfg-vmknic -l # list vmkernel interfaces and their configuration
esxcfg-nics -l # display listing of physical adapters and their link state
- 使用以下命令可在标准 vSwitch 中添加或移除网卡(称为 vmnic):
esxcfg-vswitch -U vmnic vSwitch # unlink an uplink
esxcfg-vswitch -L vmnic vSwitch # add an uplink
- 使用以下命令可在 vNetwork Distributed Switch (vDS) 中添加或移除网卡(称为 vmnic):
esxcfg-vswitch -Q vmnic -V dvPort_ID_of_vmnic dvSwitch # unlink/remove a vDS uplink
esxcfg-vswitch -P vmnic -V unused_dvPort_ID dvSwitch # add a vDS uplink
如果将管理网络连接迁移到 Distributed Switch 时连接断开,则可能需要移除或禁用现有管理 vmkernel 接口,并在标准 vSwitch 端口组中使用相同的 IP 配置重新创建该接口。
- 在 vSphere Distributed Switch (vDS) 上,使用以下命令删除现有 VMkernel 端口:
esxcfg-vmknic -d -s DVswitchname -v virtual_port_ID
注意:可使用 esxcfg-vswitch -l 命令获取虚拟端口 ID 和 Dvswitchname。
- 移除不可访问的 vmkernel 端口后,可在标准交换机上重新创建该端口。如果不存在现有标准交换机,您可以使用以下命令创建新的标准交换机以及要使用的端口组:
esxcfg-vswitch -a vSwitch
esxcfg-vswitch -A portgroup vSwitch
注意:创建虚拟交换机时,默认情况下不存在链接 vmnic。您需要按照本文前文所述链接 vmnic。
- 要创建 VMkernel 端口并将其附加到标准 vSwitch 上的端口组,请运行以下命令:
esxcfg-vmknic -a -i IP_address -n netmask -p portgroup
注意:默认情况下,ESXi 管理 vmkernel 端口为 vmk0,并驻留在名为“管理网络”的标准交换机端口组中。
- 如果与管理网络相关联的 vmnic 是 VLAN 中继,则可能需要为管理端口组指定 VLAN ID。要设置或更正标准 vSwitch 上管理连接所需的 VLAN ID,请运行以下命令:
esxcfg-vswitch -v VLANID -p portgroup vSwitch
- 如果尽管网络连接的配置正确但网络连接未还原,则可能需要重新启动主机的管理代理:
services.sh restart
在 ESX 3.x 和 4.x 中
要将管理 vmkernel 接口还原为正确的 vmnic 接口,请执行以下操作:
- 使用以下命令查看当前 vSwitch 配置和 vmkernel 接口配置:
esxcfg-vswitch -l # list current vswitch configuration
esxcfg-vmknic -l # list vmkernel interfaces and their configuration
esxcfg-nics -l # display listing of physical adapters and their link state
- 使用以下命令可在标准 vSwitch 中添加或移除网卡(称为 vmnic):
esxcfg-vswitch -U vmnic vSwitch # unlink an uplink
esxcfg-vswitch -L vmnic vSwitch # add an uplink
- 使用以下命令可在 vNetwork Distributed Switch (vDS) 中添加或移除网卡(称为 vmnic):
esxcfg-vswitch -Q vmnic -V dvPort_ID_of_vmnic dvSwitch # unlink/remove a vDS uplink
esxcfg-vswitch -P vmnic -V unused_dvPort_ID dvSwitch # add a vDS uplink
如果将管理网络连接迁移到 vSphere Distributed Switch 时连接断开,则可能需要移除或禁用现有服务控制台接口,并在标准 vSwitch 端口组中使用相同的 IP 配置重新创建该接口。
- 在 vSphere Distributed Switch (vDS) 上,使用以下命令删除现有服务控制台端口:
esxcfg-vswif -d -V DVSwitch_Name -P DVPort_ID vswifX
注意:可使用 esxcfg-vswitch -l 命令获取虚拟端口 ID 和 Dvswitchname。
- 移除不可访问的 vmkernel 端口后,可在标准交换机上重新创建该端口。如果不存在现有标准交换机,您可以使用以下命令创建新的标准交换机以及要使用的端口组:
esxcfg-vswitch -a vSwitch
esxcfg-vswitch -A portgroup vSwitch
注意:创建虚拟交换机时,默认情况下不存在链接 vmnic。您需要按照本文前文所述链接 vmnic。
- 要创建服务控制台端口并将其附加到标准 vSwitch 上的端口组,请运行以下命令:
esxcfg-vswif -a -i ipaddress -n netmask -p portgroup vswif0
注意:默认情况下,ESX 服务控制台端口为 vswif0,并驻留在名为“服务控制台”的标准交换机端口组中。
- 如果与管理网络相关联的 vmnic 是 VLAN 中继,则可能需要为管理端口组指定 VLAN ID。要设置或更正标准 vSwitch 上管理连接所需的 VLAN ID,请运行以下命令:
esxcfg-vswitch -v VLANID -p portgroup vSwitch
- 如果尽管网络连接的配置正确但网络连接未还原,则可能需要重新启动主机的管理代理:
service network restart
有关 ESXi 4.x 和 5.x 命令,请参见 vSphere Command-Line Interface Installation and Scripting Guide。
注意:通过 vNetwork Distributed Switch 运行 esxcfg-vswitch 命令时,命令行工具提供的功能有限。例如,无法使用以下命令创建 dvportgroup 或向 dvportgroup 分配 VLAN ID。某些任务必须在 vCenter Server 中使用 vSphere Client 或 vSphere Web Client 完成。
Related Information
如需了解相关信息,请参见:
- Configuring a VLAN on a portgroup (1003825)
- Configuring networking from the ESX service console command line (1000258)
- Specifying or changing the NIC teaming policy from the command line in ESX/ESXi 4.x and ESXi 5.x (1019864)
Configuring vSwitch or vNetwork Distributed Switch from the command line in ESXi/ESX
Request a Product Feature
文章末尾固定信息
评论