现象
虚拟机启动时如下提示
分析
使用vmware自带的工具分析其网络设备状态:
$ vmware-networks --status
Failed to initialize
ubuntu@u2004:~$ sudo vmware-networks --status
Bridge networking on vmnet0 is running
DHCP service on vmnet1 is running
Hostonly virtual adapter on vmnet1 is enabled
DHCP service on vmnet8 is not running
NAT service on vmnet8 is not running
Hostonly virtual adapter on vmnet8 is disabled
Some/All of the configured services are not running
其中显示:Hostonly virtual adapter on vmnet8 is disabled。
于是,尝试手动启动,失败。
$ sudo vmware-networks --start
Started Bridge networking on vmnet0
Enabled hostonly virtual adapter on vmnet1
Started DHCP service on vmnet1
Subnet on vmnet8 is no longer available for usage, please run the network editor to reconfigure different subnet
Failed to start some/all services
查看网络日志,部分日志如下:
Oct 24 15:05:42 VNLNetCfgEnumDHCPMACToIP - List of mappings is empty
Oct 24 15:05:42 VNL_UpdateDHCPFromConfig - Writing DHCP configuration file succeeded for vnet: vmnet8
Oct 24 15:05:42 VNLFileExists - Cannot check for file or directory: /etc/vmware/vmnet8/nat/nat.conf , error: No such file or directory
Oct 24 15:05:42 VNLCreateFile - Directory: /etc/vmware/vmnet8 already exists
Oct 24 15:05:42 VNLNetCfgEnumNATPortFwd - List of forwarded ports is empty
Oct 24 15:05:42 VNLNetCfgEnumNATPortFwd - List of forwarded ports is empty
Oct 24 15:05:42 VNL_UpdateNATFromConfig - Writing NAT configuration file succeeded for vnet: vmnet8
Oct 24 15:05:42 VNL_UpdateDHCPFromConfig - Removing DHCP configuration file succeeded for vnet: vmnet9
Oct 24 15:05:42 VNL_UpdateNATFromConfig - Removing NAT configuration file succeeded for vnet: vmnet9
Setting vmnet-dhcp IP address: 172.16.49.254
Opened: /dev/vmnet1
Recving on VNet/vmnet1/172.16.49.0
Sending on VNet/vmnet1/172.16.49.0
Forked child process, pid=1494
Oct 24 15:08:53 VNL_StartService - Started “DHCP” service for vnet: vmnet1
Failed to start some/all services
Oct 24 15:41:11 VNL_Load - LOG_OK logged
Oct 24 15:41:11 VNL_Load - Successfully initialized Vnetlib
Oct 24 15:41:11 VNLPingAndCheckSubnet - Return value of vmware-ping: 0
Oct 24 15:41:11 VNL_CheckSubnetAvailability - Subnet: 192.168.16.0 on vnet: vmnet8 is not available
Oct 24 15:41:12 VNL_Unload2 - Vnetlib unloaded.
Oct 24 16:03:10 VNL_Load - LOG_ERR logged
Oct 24 16:03:10 VNL_Load - LOG_WRN logged
Oct 24 16:03:10 VNL_Load - LOG_OK logged
Oct 24 16:03:10 VNL_Load - Successfully initialized Vnetlib
Oct 24 16:03:10 VNL_Unload2 - Vnetlib unloaded.
Oct 24 16:03:17 VNL_Load - LOG_ERR logged
Oct 24 16:03:17 VNL_Load - LOG_WRN logged
Oct 24 16:03:17 VNL_Load - LOG_OK logged
Oct 24 16:03:17 VNL_Load - Successfully initialized Vnetlib
Oct 24 16:03:17 VNLPingAndCheckSubnet - Return value of vmware-ping: 0
Oct 24 16:03:17 VNL_CheckSubnetAvailability - Subnet: 192.168.16.0 on vnet: vmnet8 is not available
Oct 24 16:03:18 VNL_Unload2 - Vnetlib unloaded.
经检查有这个文件: /etc/vmware/vmnet8/nat/nat.conf,从文件创建时间看,应该是日志显示时修改过的。
查看网络配置文件:
$ cat /etc/vmware/networking
VERSION=1,0
answer VNET_1_DHCP yes
answer VNET_1_DHCP_CFG_HASH 5205CD20C2ABBFC5BE4F3BF834B14E380183528A
answer VNET_1_HOSTONLY_NETMASK 255.255.255.0
answer VNET_1_HOSTONLY_SUBNET 172.16.49.0
answer VNET_1_VIRTUAL_ADAPTER yes
answer VNET_8_DHCP yes
answer VNET_8_DHCP_CFG_HASH DE31AE240D28906CBBE16CE55BD334FD0321EB60
answer VNET_8_HOSTONLY_NETMASK 255.255.255.0
answer VNET_8_HOSTONLY_SUBNET 192.168.16.0
answer VNET_8_NAT yes
answer VNET_8_VIRTUAL_ADAPTER yes
PS: 说句题外话,其实vmnet1与vmnet8几乎一样,只是vmnet8多了一个NAT到外网。
把VNET_8_HOSTONLY_SUBNET
改为192.268.15.0
,重启Host机,没效果。
那再看看安装了哪些组件,VMWare的组件安装器是使用Python编写的,一堆的Python小文件:
$ sudo ./VMware-Player-Full-16.2.0-18760230.x86_64.bundle -t
Extracting VMware Installer...done.
Component Name Component Long Name Component Version
============================ ================================================= ====================
vmware-installer VMware Installer 3.0.0.18760230
vmware-player-setup VMware Player Setup 16.2.0.18760230
vmware-usbarbitrator VMware USB Arbitrator 20.5.0.18760230
vmware-network-editor VMware Network Editor 16.2.0.18760230
vmware-vmx VMware VMX 16.2.0.18760230
vmware-virtual-printer VMware Virtual Printer 1.0.18760230
vmware-tools-linuxPreGlibc25 VMware Tools for legacy Linux 11.3.5.18760230
vmware-tools-linux VMware Tools for Linux 11.3.5.18760230
vmware-tools-netware VMware Tools for NetWare 11.3.5.18760230
vmware-tools-solaris VMware Tools for Solaris 11.3.5.18760230
vmware-tools-winPre2k VMware Tools for Windows 95, 98, Me and NT 11.3.5.18760230
vmware-tools-winPreVista VMware Tools for Windows 2000, XP and Server 2003 11.3.5.18760230
vmware-tools-windows VMware Tools for Windows Vista or later 11.3.5.18760230
vmware-player-app VMware Player Application 16.2.0.18760230
vmware-ovftool VMware OVF Tool component for Linux 4.4.3.18760230
vmware-player VMware Player 16.2.0.18760230
再看看组件vmware-network-editor
的安装器脚本们:
$ sudo ./VMware-Player-Full-16.2.0-18760230.x86_64.bundle -L vmware-network-editor
Extracting VMware Installer...done.
/etc/vmware-installer/components/vmware-network-editor/16.2.0/include/versions.py
/etc/vmware-installer/components/vmware-network-editor/16.2.0/include/__pycache__/versions.cpython-39.pyc
/etc/vmware-installer/components/vmware-network-editor/16.2.0/include/systemType.py
/etc/vmware-installer/components/vmware-network-editor/16.2.0/include/__pycache__/systemType.cpython-39.pyc
/etc/vmware-installer/components/vmware-network-editor/16.2.0/__init__.py
/etc/vmware-installer/components/vmware-network-editor/16.2.0/__pycache__/__init__.cpython-39.pyc
/etc/vmware-installer/components/vmware-network-editor/16.2.0/include/initscript.py
/etc/vmware-installer/components/vmware-network-editor/16.2.0/include/__pycache__/initscript.cpython-39.pyc
/etc/vmware-installer/components/vmware-network-editor/16.2.0/include/update.py
/etc/vmware-installer/components/vmware-network-editor/16.2.0/include/__pycache__/update.cpython-39.pyc
/etc/vmware-installer/components/vmware-network-editor/16.2.0/vmware-network-editor.py
/etc/vmware-installer/components/vmware-network-editor/16.2.0/__pycache__/vmware-network-editor.cpython-39.pyc
/usr/lib/vmware/lib/libvmware-netcfg.so/libvmware-netcfg.so
/usr/lib/vmware/bin/vmware-netcfg
即他们把下面的几个主要文件安装至系统:
/usr/lib/vmware/lib/libvmware-netcfg.so/libvmware-netcfg.so
/usr/lib/vmware/bin/vmware-netcfg
想运行网络编辑network editor这个组件/usr/lib/vmware/bin/vmware-netcfg
,命令行没法单独运行。
$ file /usr/lib/vmware/bin/vmware-netcfg
/usr/lib/vmware/bin/vmware-netcfg: symbolic link to /usr/lib/vmware/bin/appLoader
ubuntu@u2004:~/Downloads$ file /usr/lib/vmware/bin/appLoader
/usr/lib/vmware/bin/appLoader: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.4, BuildID[sha1]=9322b0ef3bb456d9b7ff73709b901ad603a03289, stripped
$ /usr/lib/vmware/bin/appLoader
[AppLoader] "appLoader" cannot be run as a standalone program.
PS: /usr/lib/vmware/bin/vmplayer
也是 symbolic link to /usr/lib/vmware/bin/appLoader
,其它一堆命令也是,为何运行/usr/lib/vmware/bin/vmplayer
却不会提示如上错误呢?
那VMware Workstation Player的network editor GUI程序入口在哪里?
其实刚才多此一举,直接运行vmware-netcfg
即可打开network editor的GUI.
PS: ssh -x
远程情况下无法打开Virtual Network Editor的GUI, 提示
$ vmware-netcfg
==== AUTHENTICATING FOR org.freedesktop.policykit.exec ===
Authentication is needed to run `/usr/bin/vmware-netcfg' as the super user
Authenticating as: ubuntu,,, (ubuntu)
Password:
polkit-agent-helper-1: error response to PolicyKit daemon: GDBus.Error:org.freedesktop.PolicyKit1.Error.Failed: No session for cookie
==== AUTHENTICATION FAILED ===
Error executing command as another user: Not authorized
PS:严格来说,Virtual Network Editor GUI只有Pro版本才有的功能,主程序界面没有入口,所以在Linux下,需要从命令行寻找启动入口。
那,Windows下VM Player如何修改vmnet8的subnet呢,目前有两个方法:
- 从VMware Workstation Player安装包中解压找出 network.cab,现解压找出 vmnetcfg.exe,
- 使用player.exe同目录下的vnetlib.exe,此程序本身设计不单独使用的,但研究人员整理了一份使用文档,VMware Workstation Player 4个服务 adapter, authd, bridge and vmkbd 都基于这个程序入口,足见重要性。
解决
按照出错的提示,修改vmnet8的子网,重启Host机,vmnet8就恢复正常了,ip a
也能正常看到了。
$ sudo vmware-networks --status
Bridge networking on vmnet0 is running
DHCP service on vmnet1 is running
Hostonly virtual adapter on vmnet1 is enabled
DHCP service on vmnet8 is running
NAT service on vmnet8 is running
Hostonly virtual adapter on vmnet8 is enabled
All the services configured on all the networks are running
但,如果只是手动修改/etc/vmware/networking
这个文件后重启系统,是没有效果的。因为其还有其它相关配置文件也需要修改,如/etc/vmware/vmnet8/nat/nat.conf
等。
原因
原因应该是所在网络环境已经有了vmnet8期望使用的192.168.16.1/24
地址,特别是192.168.16.1
。
比如,局域网中其它机子最近配置了192.168.16.1
地址。
参考:VMware Workstation – Virtual Ethernet failed – sometimes for good!