We all have used virtual machines now or then, and they come in very handy when someone wants to run multiple instances of different operating systems in one go, or their main operating system. When you work with virtual machines it’s important to connect them to a local network or to be able to access the internet through VM. So in this article, we will see two methods by which you will be able to set up a network bridge in your virtual machine. To do so follow the step-by-step guide below.
Method 1: Using VirtualBox GUI manager
Step 1: Open the VirtualBox manager
Go to your search bar or taskbar and open the installed virtual machine, in our case which is a virtual Box. Using a virtual box for creating a network bridge will be an easy task.
Step 2: Open Virtual Box Settings
Right click on the VM and choose “Settings” from the context or you can go to machine option on the top left corner and click on settings in it.
Step 3: Network Settings
After getting a settings window popped up you will see a option of network in the side bar, click it and it will open network settings.
Step 4: Configure Adapter 1
You will see adapter one and bunch of options in it, by default adapter 1 is set to NAT which provides access to internet but doesn’t bridge to the host network, change the attached to dropdown to “Bridged Adapter”.
Step 5: Select Bridge Adapter
In the name dropdown, select the physical network adapter you want to bridge to. This is typically the network interface that connects to your local network. In our case it is our inbuilt network card/ interface.
Step 6: Save Settings
Click on ok Button and save the network settings for your Virtual Machine,and with this final step we are done. We have configured our VM to provide Bridged network with our local network and within the machines/ instances we are running in VM.
Method 2: Using nmcli in linux
The nmcli command is a command-line tool for managing network connections in Linux. To set up a network bridge using the nmcli command, follow these steps:
Step 1: Open your terminal and run the following command:
nmcli connection add type bridge ifname br0
In the above command br0 is the name that we choose to give to the bridge connection , you can type in any name you like.
Step 2: Run the following command to add the physical network interface to the bridge:
nmcli connection add type bridge-slave ifname eth0 master br0 con-name br0-enp0s3
Now look carefully we have used our physical interface name that is eth0 in my case. You have to type your physical interface name which you can see by typing IP link in terminal and further more we have br0-enp0s3 this is just our connection name we choose to give, you can give any name you like.
Step 3: Run the following command to start the bridge:
nmcli connection up br0
After this our bridge is ready and in use by our system. You can verify it by opening network manager in linux. You can see in the below image we have our bridge connection listed in networks and bridges.
Conclusion
With the help of this article you will be able to set up a network bridge in VirtualBox, enabling your virtual machine to connect to your local network or the internet with ease. You can always explore more and try on new configurations with systems. You can enhance the networking capabilities of your VMs and make them an integral part of your network infrastructure.