vSphere支持在命令行(CLI)的方式下修改网络配置,对4.1以上版本,使用:console-setup命令即可完成操作:

 

Configuring or restoring networking from the ESX service console using console-setup
Purpose
This article provides steps to configure or restore networking for an ESX host when you only have access to the service console.
Resolution
ESX 4.0 Update 2 introduces a new tool (console-setup) to simplify the process of creating or restoring networking in the ESX service console.
VMware recommends that you use the physical console of the server rather than connecting via SSH as changing the network configuration might cause a disconnection, which can leave the server unreachable.
 
The tool allows you to perform the most common steps required to restore the ESX server's network connectivity via simple menu items, such as changing or correcting:
·    IP address
·    Net mask
·    Default gateway
·    VLAN ID
·    Physical uplink (vmnic)
The tool does not currently support configuring the service console interface via DHCP. For this case, see Configuring networking from the ESX service console command line (1000258).
When you console-setup as root from the service console, you are presented with this menu:
1. Show Current Service Consoles
2. Show Network Adapters
3. Show vSwitch/vDS Information
4. Delete Service Console
4.1 Select the interface to delete, defaults to vswif0
5. Configure Service Console
5.1 vswif ID, default to vswif0
5.2 Name of service console port group: default to “Service Console”
5.3 vSwitch for service console, default to vSwitch0
5.4 IP Address:
5.5 Subnet mask:
5.6 Default gateway:
5.7 VLAN ID: default to 0
5.8 vmnic to use for the service console
5.9 Save Changes
5.10 Return to Menu
6. Exit
Use:
·    Options 1,2 and 3 for display current information
·    Option 4 to remove an existing service console interface (vswif). You may also do this, if you want to recreate it.
·    Option 5 to change the configuration of an existing vswif interface, or for creating a new one.

 

 

 

如果没有console-setup,可以使用以下命令:

 

 
Solution
Note: ESX 4.0 Update 2 introduces a new tool that simplifies the process of creating or restoring networking in the ESX service console. For more information, see Configuring or restoring networking from the ESX service console using console-setup (1022078).
 
To delete and recreate a virtual switch and Service Console from the command line:
 
Note: On your system the vswif, vmnic, vSwitch numbers and network settings are different. 
1.     Run the following command to list the name of the vswif adapter:

esxcfg-vswif -l
2.     Run the following command to delete the vswif adapter:

esxcfg-vswif --del vswif0
3.     Run the following command to list the name of the vSwitch:

esxcfg-vswitch -l
4.     Run the following command to delete the vSwitch:

esxcfg-vswitch -d vSwitch0
5.     Run the following command to create the vSwitch:

esxcfg-vswitch -a vSwitch0
6.     Run the following commands to create default port groups for vSwitch:

esxcfg-vswitch -A "VM Network" vSwitch0
esxcfg-vswitch -A "Service Console" vSwitch0
7.     Run the following command to create the vswif adapter:

esxcfg-vswif --add --portgroup "Service Console" --ip=nnn.nnn.nnn.nnn --netmask=255.255.255.0 vswif0 
8.     Run the following command to verify that the settings in the network file are correct:

cat /etc/sysconfig/network

NETWORKING=yes
GATEWAYDEV=vswif0
HOSTNAME=host.domain.com
GATEWAY=nnn.nnn.nnn.nnn
9.     Run the following commands to list all of the network adapters and associate a vmnic which has a link status of up:

esxcfg-nics -l
esxcfg-vswitch -L vmnic1 vSwitch0
10.   Run the following command to verify that the vmnic is associated with the vSwitch:

esxcfg-vswitch -l
11.   Ping an IP address to check for network connectivity. If the ping fails, remove the previous vmnic from the vSwitch and try another adapter that has a link status of up.

esxcfg-vswitch -U vmnic1 vSwitch0
esxcfg-vswitch -L vmnic2 vSwitch0
12.   Run the following command to change the vlan ID of a vSwitch:

[root@server root]# esxcfg-vswitch -p "VM Network 1" -v 10 vSwitch0

13.   If you make any manual changes to /etc/sysconfig/network, run the following command to restart the network service:

service network restart

 

 

有一点必须要注意:确保连接到ESX主机的交换机端没有做端口聚合。