且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

VMware网络配置常用的命令

更新时间:2022-06-04 22:12:29

 修改控制台通信端口(Service Consol):

查看信息:esxcfg-vswif -l

# esxcfg-vswif -l

Name Port Group/DVPort IP Family IP Address Netmask Broadcast Enabled TYPE

vswif0 Service Console-1 IPv4 192.168.1.120 255.255.255.0 192.168.1.255 true STATIC

vswif1 Service Console 2 IPv4 192.168.5.99 255.255.255.0 192.168.5.255 true STATIC

操作命令:

启用和禁用接口:esxcfg-vswif -e VSWIF_NAME 和 esxcfg-vswif -s VSWIF_NAME

启用所有的接口:esxcfg-vswif -E|--enable-all

添加和删除接口:esxcfg-vswif -a VSWIF_NAME和 esxcfg-vswif -d VSWIF_NAME

关于添加一个consolIP的步骤及详细参数:

一、先检查哪些虚拟交换机上预留了哪些service consol接口

# esxcfg-vswitch -l

Switch Name Num Ports Used Ports Configured Ports MTU Uplinks

vSwitch0 32 3 32 1500

 

PortGroup Name VLAN ID Used Ports Uplinks

VM Network-1 0 2

 

Switch Name Num Ports Used Ports Configured Ports MTU Uplinks

vSwitch1 64 7 64 1500 vmnic1

 

PortGroup Name VLAN ID Used Ports Uplinks

Service Console 2 0 1 vmnic1

VM Network-2 0 3 vmnic1

VMkernel 0 1 vmnic1

 

Switch Name Num Ports Used Ports Configured Ports MTU Uplinks

vSwitch2 64 1 64 1500

 

PortGroup Name VLAN ID Used Ports Uplinks

Virtual Machine Network0 0

可以看到虚拟交换机vSwitch0没有与任何实体网卡相连。

二、给虚拟交换机连接实体网卡

查看服务器已有的实体网卡信息:

# esxcfg-nics -l

Name PCI Driver Link Speed Duplex MAC Address MTU Description

vmnic0 06:07.00 e1000 Up 100Mbps Full 00:11:43:36:73:77 1500 Intel Corporation 82541GI Gigabit Ethernet Controller

vmnic1 07:08.00 e1000 Up 100Mbps Full 00:11:43:36:73:78 1500 Intel Corporation 82541GI Gigabit Ethernet Controller

假设我们要把vmnic0这块实体网卡接到虚拟交换机vSwitch0上,可以这样操作:

# esxcfg-vswitch -L vmnic0 vSwitch0

注:

如果是想断开与实体网卡的连接可以这样操作

# esxcfg-vswitch -U vmnic0 vSwitch0

重新检查一下:# esxcfg-vswitch -l

Switch Name Num Ports Used Ports Configured Ports MTU Uplinks

vSwitch0 32 4 32 1500 vmnic0

 

PortGroup Name VLAN ID Used Ports Uplinks

VM Network-1 0 2 vmnic0

 

Switch Name Num Ports Used Ports Configured Ports MTU Uplinks

vSwitch1 64 7 64 1500 vmnic1

 

PortGroup Name VLAN ID Used Ports Uplinks

Service Console 2 0 1 vmnic1

VM Network-2 0 3 vmnic1

VMkernel 0 1 vmnic1

 

Switch Name Num Ports Used Ports Configured Ports MTU Uplinks

vSwitch2 64 1 64 1500

 

PortGroup Name VLAN ID Used Ports Uplinks

Virtual Machine Network0 0

可以看到vSwitch0已经连接到vmnic0上了。

三、检查当前的service consol状况

发现虚拟交换机vSwitch0没有控制台通信端口,为虚拟交换机vSwitch0添加控制台通迅端口Serveice Console 1

# esxcfg-vswitch -A Service\ Console\ 1 vSwitch0

注:

如果是想删除一个通信端口组可以这样操作

# esxcfg-vswitch -D Service\ Console\ 1 vSwitch0

重新检查一下:# esxcfg-vswitch -l

# esxcfg-vswitch -l

Switch Name Num Ports Used Ports Configured Ports MTU Uplinks

vSwitch0 32 4 32 1500 vmnic0

 

PortGroup Name VLAN ID Used Ports Uplinks

Service Console 1 0 0 vmnic0

VM Network-1 0 2 vmnic0

 

Switch Name Num Ports Used Ports Configured Ports MTU Uplinks

vSwitch1 64 7 64 1500 vmnic1

 

PortGroup Name VLAN ID Used Ports Uplinks

Service Console 2 0 1 vmnic1

VM Network-2 0 3 vmnic1

VMkernel 0 1 vmnic1

 

Switch Name Num Ports Used Ports Configured Ports MTU Uplinks

vSwitch2 64 1 64 1500

 

PortGroup Name VLAN ID Used Ports Uplinks

Virtual Machine Network0 0

可以看到默认情况下控制台通信端口Service Console 1已经与实体网卡vmnic0连接好了。

四、添加与控制台通信端口相对应的虚拟网卡

添加与控制台通信端口Service Console 1对应的虚拟网卡,并配置IP信息:

# esxcfg-vswif -a vswif0 -p Service\ Console\ 1 -i 192.168.1.120 -n 255.255.255.0 -b 192.168.1.255

[2010-12-07 17:06:47 'Vnic' warning] Generated New MAC address, 00:50:56:4a:c3:45 for vswif0

Nothing to flush.

注:

如果是想删除与控制台通信端口相对应的虚拟网卡可以这样操作

# esxcfg-vswif -d vswif0

重新检查一下:

# esxcfg-vswif -l

Name Port Group/DVPort IP Family IP Address Netmask Broadcast Enabled TYPE

vswif0 Service Console 1 IPv4 192.168.1.120 255.255.255.0 192.168.1.255 true STATIC

vswif1 Service Console 2 IPv4 192.168.5.99 255.255.255.0 192.168.5.255 true STATIC

已经多出来了一个叫做vswif0的虚拟网卡,IP地址为192.168.1.120,我们可以通过访问这个IP来做一些管理性的工作。

 

 

 

     本文转自xiaoyuwang 51CTO博客,原文链接:http://blog.51cto.com/wangxiaoyu/462345,如需转载请自行联系原作者