7.39. VBoxManage dhcpserver

The dhcpserver commands enable you to control the DHCP server that is built into Oracle VM VirtualBox. You may find this useful when using internal or host-only networking. Theoretically, you can also enable it for a bridged network, but that may cause conflicts with other DHCP servers in your physical network.

Use the following command line options:

  • If you use internal networking for a virtual network adapter of a virtual machine, use VBoxManage dhcpserver add --netname <network_name>, where <network_name> is the same network name you used with VBoxManage modifyvm <vmname> --intnet<X> <network_name>.

  • If you use host-only networking for a virtual network adapter of a virtual machine, use VBoxManage dhcpserver add --ifname <hostonly_if_name> instead, where <hostonly_if_name> is the same host-only interface name you used with VBoxManage modifyvm <vmname> --hostonlyadapter<X> <hostonly_if_name>.

    Alternatively, you can also use the --netname option as with internal networks if you know the host-only network's name. You can see the names with VBoxManage list hostonlyifs. See Section 7.4, “VBoxManage list”.

The following additional parameters are required when first adding a DHCP server:

  • With --ip, specify the IP address of the DHCP server.

  • With --netmask, specify the netmask of the network.

  • With --lowerip and --upperip, you can specify the lowest and highest IP address that the DHCP server will assign to clients.

You can specify additional DHCP options with the --options command option. Use --id and --value to configure a number and string pair corresponding to the DHCP option. Use --remove to remove a DHCP option.

The --vm and --nic settings enable you to configure DHCP options for a specific network adapter used by the named VM.

Finally, you must specify --enable or the DHCP server will be created in the disabled state and will not be running.

After this, Oracle VM VirtualBox will automatically start the DHCP server for the specified internal network or host-only network as soon as the first virtual machine which uses that network is started.

Use VBoxManage dhcpserver remove with the given --netname <network_name> or --ifname <hostonly_if_name> to remove the DHCP server for the specified internal network or host-only network.

To modify the settings of a DHCP server created using VBoxManage dhcpserver add, you can use VBoxManage dhcpserver modify for a given network or host-only interface name. This has the same parameters as VBoxManage dhcpserver add.