How to Enable Internet Connectivity in VirtualBox | Linux



VirtualBox is a popular virtualization platform that allows users to run multiple virtual machines (VMs) on a single physical host. To make the most of your virtual machines, it's essential to ensure they have internet access. In this guide, we'll walk you through the steps to enable internet connectivity in VirtualBox using Network Address Translation (NAT) and Bridged Adapter modes.

Step 1: Launch VirtualBox and Open Your VM:

Start by launching VirtualBox and opening the virtual machine you want to enable internet access for.

Step 2: Configure Network Adapter:

Click on the virtual machine in the VirtualBox Manager to select it. Go to the "Settings" menu and navigate to the "Network" section.



Enabling Internet Access via NAT

  1. In the "Attached to" dropdown, select "NAT (Network Address Translation)."  NAT allows your VM to share the host's internet connection.


Enabling Internet Access via Bridged Adapter

  1. If you prefer using a Bridged Adapter, select "Bridged Adapter" from the "Attached to" dropdown. In the "Name" dropdown (available only if you selected Bridged Adapter), choose your host computer's network interface. This interface provides direct access to your network.



Step 3: Verify Network Interfaces:

To check available network interfaces on your VM, open a terminal within the VM. Give this command : 

ifconfig

This command will display information about the network interfaces on your VM.


Step 4: Restart Network Interface (if necessary):

If you find that the internet is not working, you can try restarting the network interface using the following commands. This step is primarily applicable if you're using a Bridged Adapter and encounter connectivity issues.

sudo ifconfig eth0 down 

sudo ifconfig eth0 up

These commands will bring the network interface down and then up again to refresh the connection.



Step 5: Test Internet Connectivity:

To test your internet connection, open a terminal within your VM and ping Google's website using the following command:

ping google.com

This command will send ICMP packets to Google's servers and display the response times. If you see responses, your internet connection is working correctly.

Finally, open a web browser within your VM and try accessing a website to verify that internet access is working correctly.




Comments

Popular Posts