Posted on 3 Comments

How to enable DHCP server in VirtualBox

Good evening friends. We have seen how to create a virtual pentest lab both in Oracle VirtualBox (see here) and Vmware Workstation(see here). Although both penetration testing labs  were almost similar, there is a small difference between them . As the title of this howto already implies it is the absence of DHCP server in the pentest lab we created using Virtualbox. VirtualBox provides a DHCP server but it can’t be turned on using the GUI feature unlike Vmware Workstation. So let’s see how to enable DHCP server in Virtualbox networks. I am going to assign DHCP server to my pentest lab I created above. I will assume that  virtualbox is installed on Windows. Open CMD and navigate to the directory where  Virtualbox is installed. By default it will be “C:Program Files OracleVirtualBox”. Type the command “vboxmanage dhcpserver add –ip 10.10.10.1 –netmask 255.0.0.0 –lowerip 10.10.10.2 –upperip 10.10.10.10 –netname pentestlab”. Hit Enter.

In the above command, “vboxmanage dhcpserver  add –ip 10.10.10.1” starts a DHCP server with IP address 10.10.10.1 . The “–netmask 255.0.0.0″ assigns subnet mask for the network. The “–lowerip” and “–upperip” options assign a lower ip address and upper ip address respectively.   The “–enable” option enables the DHCP server we just created. The “–netname” option assigns a name to the network. Now we have successfully created an internal network named pentest lab with its own DHCP server. Now change the network adapter settings of the attacker machine ( Kali Linux ) to pentest lab.

Similarly change the network settings of the victim machine.

Now start the attacker machine (Kali Linux) to see if the IP address is automatically assigned. If the IP address has not been assigned, disable the adapter using command “ifdown eth0″ and re enable it by typing command “ifup eth0″. Now check if the IP address has been assigned or not by typing command “ifconfig”.

Similarly check on the victim machine.

We can see that the IP addresses have been automatically assigned successfully starting from the range of 10.10.10.2. Hope this was helpful.

Follow Us

3 thoughts on “How to enable DHCP server in VirtualBox

  1. Hi,
    I have set up pentest lab as described. I then followed the DHCP server instructions.
    I am getting the following errors.

    ifdown eth0

    ifdown: interface eth0 not configured

    ifup eth0

    ignoring unknown interface eth0=eth0

    Any ideas appreciated

    1. @paul, open a terminal and type command “ifconfig”. See whether your interface name is eth0 or something different. If it is different, try the above commands with that interface name.

  2. hello,
    the above worked very well, I was just wondering if there was a way for it to be persistent? or would i have to retype this in every time i boot up the two machines?
    thanks in advance,
    michael

Comments are closed.