手动配置 VMware DHCP 网段地址

通过手动配置 C:ProgramDataVMwarevmnetdhcp.conf (或 C:Documents and SettingsAll UsersApplication DataVMwarevmnetdhcp.conf ),修改 VMware DHCP Server 的作用域会发现 VMware DHCP 服务无法启动。

查阅相关资料发现:还要修改 VMware DHCP 服务使用的 IP。在注册表中:

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\VMnetDHCP\Parameters\VirtualEthernetSegments\1]

里边的 1HostOnly 的, 8VMware NAT 的。

"HostIpAddress"=dword:01d6a8c0

01d6a8c0 转换方法是:1,10001110-142,10101000-168,11000000-192 (就是DHCP Server的地址是 1.142.168.192,注意这个是跟正常的 VMware Net Adp1 设置的 IP 的左右反向出来的东西)。

通过 VMware 提供的命令行工具进行配置

后来发现有现成的管理命令处理 DHCP 的作用域,不过这个还是要手动修改 DHCP Server 的 IP 的。

cd "\Program Files (x86)\VMware\VMware Player\"
vnetlib.exe -- stop nat
vnetlib.exe -- stop dhcp
vnetlib.exe -- set vnet vmnet1 addr 192.168.200.0
vnetlib.exe -- update dhcp vmnet1
vnetlib.exe -- update adapter vmnet1
vnetlib.exe -- set vnet vmnet8 addr 192.168.201.0
vnetlib.exe -- update dhcp vmnet8
vnetlib.exe -- update nat vmnet8
vnetlib.exe -- update adapter vmnet8
vnetlib.exe -- start dhcp
vnetlib.exe -- start nat
net stop "VMware Authorization Service"
net stop "VMware DHCP Service"
net stop "VMware NAT Service"
net stop "VMware USB Arbitration Service"
net start "VMware Authorization Service"
net start "VMware DHCP Service"
net start "VMware NAT Service"
net start "VMware USB Arbitration Service"
pause

附上设置的方法:

  1. 设置 VMnet1
vnetlib.exe -- stop dhcp
vnetlib.exe -- set vnet vmnet8 mask 255.255.255.0
vnetlib.exe -- set vnet vmnet8 addr 192.168.52.0
vnetlib.exe -- update dhcp vmnet8
vnetlib.exe -- update adapter vmnet8
vnetlib.exe -- start dhcp
  1. 设置 VMnet8
vnetlib.exe -- stop nat
vnetlib.exe -- stop dhcp
vnetlib.exe -- set vnet vmnet8 mask 255.255.255.0
vnetlib.exe -- set vnet vmnet8 addr 192.168.52.0
vnetlib.exe -- update dhcp vmnet8
vnetlib.exe -- update nat vmnet8
vnetlib.exe -- update adapter vmnet8
vnetlib.exe -- start dhcp
vnetlib.exe -- start nat
  1. 删除 VMnet
vnetlib.exe -- remove adapter vmnet*
  1. 备份 VMnet 设置
vnetlib.exe -- export backup-file-name
  1. 导入 VMnet 备份
vnetlib.exe -- import backup-file-name
  1. 创建新的 VMnet
vnetlib.exe -- add adapter vmnet#

VNetLib用法详解:

VNETLIB - "VMware network install library executable"

Background

Vnetlib is the invisible engine working in the backgrounds of the gui tools like vmware.exe, vmnetcfg.exe and the installer. Vnetlib can install and uninstall almost all the services, as well as configuring the virtual networking. This little powerful tool can evidentally aid alot in repairing broken installations. And best of all - it's command line.
Following a string dump of vnetlib.exe the first string that caught my attention was:
"vnetlib: this utility is not intended to be run as a standalone application" .
But obviously it's possible to use it as such anyway.
This tool has never been documented by VMware!

Requirements

For taking advantage of its full potential make sure all the necessary files (inf, cat, sys, dll, exe) are located according to this registry entry:

[HKEY_LOCAL_MACHINE\Software\VMware, Inc.\VMware Workstation]

"InstallPath"="This_path_can_be_anywhere"

Namely 4 services are fully dependant on this entry: adapter, authd, bridge and vmkbd.
WMI must also be enabled if vnetlib should be able to interact with bridge. A workaround is described in the vmnetbridge section.
Vnetlib will also require that %SystemRoot% is writeable, because it copies the files found in the path mentioned above and into 3 specific folders: %SystemRoot%inf, %SystemRoot%system32 and %SystemRoot%system32drivers. This requirement only applies when installing the services.
If %SystemRoot% is read-only as is the case with certain Preinstallation Environments, then look at the alternative way of installing theses services, described later in this document.

First a list of all the services that vnetlib is able to interact with:

Vnetlib internal service nameWindows service descriptionWindows service name
vmparportVMware Paralell Port Drivervmparport
userifVMware Network Application Interfacevmnetuserif
dhcpDhcp Service for virtual networksvmnetdhcp
natNetwork address translation for virtual networksvmware nat service
bridgeVMware Bridge Protocolvmnetbridge
vmkbdVMware Keyboard Drivervmkbd
vmx86VMware Virtualization Drivervmx86
vmciVMware vmci Drivervmci
hcmonVMware USB Driverhcmon
usbVMware USB Client Drivervmusb
vmmemVMware Memory Drivervmmemct
vmcpuVMware CPU Drivervmdesched-driver
authdVMware Authorization Servicevmauthdservice
serverdVMware Registration Servicevmserverdwin32
adapterVMware Virtual Ethernet Adapter Drivervmnetadapter

The commandline switches described in this article are:

"vnetlib.exe -- install"
"vnetlib.exe -- uninstall"
"vnetlib.exe -- reinstall"
"vnetlib.exe -- start"
"vnetlib.exe -- stop"
"vnetlib.exe -- update"
"vnetlib.exe -- set"
"vnetlib.exe -- add"
"vnetlib.exe -- remove"
"vnetlib.exe -- enable"
"vnetlib.exe -- disable"
"vnetlib.exe -- import"
"vnetlib.exe -- export"

The "-- install" will take these parameters:

ParameterCommand line
authdvnetlib.exe -- install authd
bridgevnetlib.exe -- install bridge
dhcp vnetlib.exe -- install dhcp
hcmonvnetlib.exe -- install hcmon
natvnetlib.exe -- install nat
serverdvnetlib.exe -- install serverd
usb *must use rundll32 vnetlib.exe -- install usb
userifvnetlib.exe -- install userif
vmci vnetlib.exe -- install vmci
vmcpuvnetlib.exe -- install vmcpu
vmkbdvnetlib.exe -- install vmkbd
vmmemvnetlib.exe -- install vmmem
vmparportvnetlib.exe -- install vmparport
vmx86vnetlib.exe -- install vmx86

Additionally there are some special parameters for -- install:

devices -  will install 5 services; adapter, bridge, dhcp, nat, userif

vnetlib.exe -- install devices

host -  will install 3 services; hcmon, vmparport, vmx86

vnetlib.exe -- install host

The "-- uninstall" will take these parameters:

ParameterCommand line
authdvnetlib.exe -- uninstall authd
bridge vnetlib.exe -- uninstall bridge
dhcpvnetlib.exe -- uninstall dhcp
hcmonvnetlib.exe -- uninstall hcmon
nat vnetlib.exe -- uninstall nat
serverdvnetlib.exe -- uninstall serverd
usbvnetlib.exe -- uninstall usb
userifvnetlib.exe -- uninstall userif
vmcivnetlib.exe -- uninstall vmci
vmcpuvnetlib.exe -- uninstall vmcpu
vmkbd *require a reboot vnetlib.exe -- uninstall vmkbd
vmmemvnetlib.exe -- uninstall vmmem
vmparportvnetlib.exe -- uninstall vmparport
vmx86vnetlib.exe -- uninstall vmx86

Additionally there are some special parameters for -- uninstall:

legacy - will uninstall 3 services; bridge, dhcp, nat

vnetlib.exe -- uninstall  legacy

all - will uninstall 4 services; bridge, dhcp, nat, userif

vnetlib.exe -- uninstall  all

host  - will uninstall 3 services; hcmon, vmparport, vmx86

vnetlib.exe -- uninstall  host

adapter/aggressive  -  will uninstall 5 services; adapter, bridge, dhcp, nat, userif

vnetlib.exe -- uninstall  adapter

Starting & Stopping Services:

ParameterCommand line for starting serviceCommand line for stopping service
authdvnetlib.exe -- start authdvnetlib.exe -- stop authd
bridgevnetlib.exe -- start bridgevnetlib.exe -- stop bridge
dhcpvnetlib.exe -- start dhcpvnetlib.exe -- stop dhcp
hcmonvnetlib.exe -- start hcmonvnetlib.exe -- stop hcmon
natvnetlib.exe -- start natvnetlib.exe -- stop nat
serverdvnetlib.exe -- start serverdvnetlib.exe -- stop serverd
userifvnetlib.exe -- start userifvnetlib.exe -- stop userif
vmcivnetlib.exe -- start vmcivnetlib.exe -- stop vmci
vmcpuvnetlib.exe -- start vmcpuvnetlib.exe -- stop vmcpu
vmkbdvnetlib.exe -- start vmcpuvnetlib.exe -- stop vmcpu
vmmemvnetlib.exe -- start vmmemvnetlib.exe -- stop vmmem
vmparportvnetlib.exe -- start vmparportvnetlib.exe -- stop vmparport
vmx86vnetlib.exe -- start vmx86vnetlib.exe -- stop vmx86

Reinstalling services:

ParameterCommand line
allvnetlib.exe -- reinstall all
hostvnetlib.exe -- reinstall host
networkvnetlib.exe -- reinstall network
drivers/adaptersvnetlib.exe -- reinstall adapters

*Not recommended, use uninstall/install instead.

Updating the settings:

ParameterCommand line
adaptervnetlib.exe -- update adapter
allvnetlib.exe -- update all
dhcpvnetlib.exe -- update dhcp
natvnetlib.exe -- update nat

Modifying adapters:

Remove adapter vmnet6

vnetlib.exe -- remove adapter vmnet6

Add adapter vmnet9

vnetlib.exe -- add adapter vmnet9

Enable adapter vmnet5

vnetlib.exe -- enable adapter vmnet5

Disable adapter vmnet3

vnetlib.exe -- disable adapter vmnet3

*Will take vmnet0/vmnet1/vmnet2/vmnet3/vmnet4/vmnet5/vmnet6/vmnet7/vmnet8/vmnet9

Changing configuration in adapter:

Set subnet mask of vmnet8

vnetlib.exe -- set vnet vmnet5 mask 255.255.255.0

Set IP adress of vmnet5

vnetlib.exe -- set adapter vmnet5 addr 10.10.10.2

Example reconfiguration of adapter vmnet8:

vnetlib.exe -- stop nat
vnetlib.exe -- stop dhcp
vnetlib.exe -- set vnet vmnet8 mask 255.255.255.0
vnetlib.exe -- set adapter vmnet8 addr 10.11.12.2
vnetlib.exe -- update dhcp vmnet8
vnetlib.exe -- update nat vmnet8
vnetlib.exe -- update adapter vmnet8
vnetlib.exe -- start dhcp
vnetlib.exe -- start nat

Backup & Restore of settings:

Make a backup of current setting in all your configured vmnets

vnetlib.exe -- export backup-file-name

Restore vmnet-settings from a backup

vnetlib.exe -- import backup-file-name

来源:

  1. VMware Player 设置DHCP的网段
  2. Vnetlib - Documenting the command line
  3. Vnetlib - Documenting some more

标签: VMware, VMware Player, DHCP, vnetlib

添加新评论