First we will be downloading VirtualBox in order to setup Kali Linux and the Metasploitable 2 lab.
Go here: https://www.virtualbox.org/wiki/Downloads
Select the installer method you would like. In my case, I have installed VirtualBox onto a Windows instance. Before running the installer, please make sure that the VirtualBox installer file matches the SHA256 checksum on the VirtualBox page, there should be a link on the same download page. Run the following commands to check the SHA256 hash, and make sure it matches – this prevents you from downloading a potentially tampered version of the file. Do this for the install of any future VirtualBox instances or VM images such as Kali Linux and Metasploitable 2.
For WindowsCertUtil -hashfile 'file.exe' sha256
For Linuxsha256sum file.deb
NatNetwork Setup
Next, we must setup a NatNetwork so that the Kali Linux VM will be able to reach the Metasploitable 2 box for testing. To do that, you must select “Tools” from the VirtualBox menu, and create a new NatNetwork, follow the below settings in the screenshot below to configure your subnet:

