Our lab setup involves two identical virtual machines in VirtualBox. Explore how to configure the networks on both, so they get IP addresses on the local physical network. Discover how this allows other physical hosts as well as the VirtualBox host to communicate with the virtual machines. Learn that both virtual machines can also communicate with each other. Also, test this behavior before moving on.
- [Narrator] In order to configure and test Linux networking using Virtual Box, we need more than one virtual machine. We will need two VMs. We want both VMs to access the other's network interfaces. We may also want to have the Virtual Box host or other computers on the physical network to have network connectivity with the VM guest. In order to do this, we we'll need to configure the VM network interfaces. In order to clone our VM, we need to make sure it's shut down. If you VM is running, shut it down now using Virtual Box Manager. Once it's shut down, we can continue.
To configure the network interface settings, click the VM and then click on Settings and then click on Network. We want to change Attached to NAT to Attached to Bridged Adapter. In the Name section, make sure you select the physical network adapter of your host machine that has access to the Internet. In my case, the host is running on Linux and I'm using the wireless network adapter, so I'm going to choose wlp3s0 which is the name my Linux host installation has chosen for it. If you're using Mac OS or Windows as your host, choose the appropriate network interface that your host is using.
Once that's done, click on Okay. We also need to discard the saved state, so our VMs boot up fresh for the first time. If you don't do this, then all of you Vms will boot up and assume the same IP address, because that is a live setting in RAM which is included in the save state. Make sure your VM is selected and then, click on this card and then, click on this card again. Once we have our VM network adapter configured, we want to clone the VM. In the Virtual Box Manager window, go to Machine and then click on Clone.
A dialog box asking for the name should appear. Let's name this rhhost1 and click on Reinitialize the MAC address of all network cards and this is so all network cards have a unique MAC address, so even though the rest of the VM is identical, the MAC addresses won't be. Now, click on Next. Now, we have to choose a type of clone we want. A Full clone makes a completely independent VM that could be moved without the original, but takes up and equal amount of disk space as the original.
If you foresee moving one VM without the other, you may want to choose Full clone here. However, for our purposes, making a Linked clone is perfectly fine and uses less disk space. I'm going to choose Linked clone and then, click on Clone and now I'll make sure the original VM is selected and let's make a second clone. Go to Machine, click on Clone and this one we're going to call rhhost2 and then, click on Reinitialize the MAC address of all network cards. Click Next. Select Linked clone and then, click on Clone.
Now, we should have two virtual machines named rhhost1 and rhhost2. Let's configure their networks. Click on rhhost1 and click on Start. After your VM boots up, login when prompted. On the desktop, click on the top right-hand menu. Click on Wired and then, click on Wired Settings. Click the On/Off slider to turn the network on.
When it retrieves an IP address, note that the address should be on the same network as you host computer. If it's an address that starts with 10., the network configuration settings in Virtual Box might not correct unless your physical network also starts with 10.; remember this IP address as we'll need it later to ensure connectivity. Mine is 192.168.0.19; then, click the settings gear in the bottom right-hand corner. Click on Identity and click Connect automatically.
Then, click on apply and close the dialog. Before we start our second VM, let's create a new snapshot by pressing the host key + T. My host key is right CTRL, so I'm going to right CTRL + T and we're going to call the snapshot Network Config and hit Enter. Once this is done, press you host key again to release your mouse pointer, go back to your Virtual Box Manager, click on rhhost2 and click on Start.
On the desktop, go to the top right-hand menu, click on Wired, Wired settings and then, click on the slider button to turn the network on. Then, we'll click on the settings gear and we'll click on Identity and click on Connect automatically. Click Apply and close the dialog. Now we have two running virtual machines with the network interfaces on the same network. While we're still using rhhost2, let's open the Terminal by going to Application, Favorites, Terminal. I'm going to make mine full screen and bump my font size.
Then, to ensure connectivity with rhhost1, let's ping it by typing in ping, space, followed by the IP address of rhhost1. In my case, I type ping, space, 192.168.0.19; after it sends a couple of ping packets, press CTRL + C to cancel it; if it successfully pings rhhost1 by IP address, you can continue with this course. If not, go over the steps in this video until you get it to work. Do not proceed on until these steps work.
Otherwise, the course cannot be completed. Before we end this video, let's create a new snapshot of our rhhost2 VM. Close your Terminal window and then press host key + T. In my case, again, my host key is right CTRL, space, T and this snapshot we're going to call Network Config and hit Enter. You can now shut down both VMs by clicking the Close Gadget, selecting the Power off the machine and making sure Restore current snapshot 'Network Config' is selected.
- Gathering network information
- Ensuring connectivity with ping
- Querying DNS servers with dig
- Changing hostname, IP address, and more
- Configuring networking
- Connecting to SSH
- Configuring SSH clients
- Authenticating and restricting access with SSH
- Optimizing SSH for speed