How to Configure Networking for a Linux 7 Virtual Machine in Oracle VirtualBox

How to Configure Networking for a Linux 7 Virtual Machine in Oracle VirtualBox

Networking is an essential part of working with virtual machines (VMs), as it enables communication with other devices and access to the internet. In this guide, we will configure networking for a Linux 7 VM in Oracle VirtualBox. The steps will include setting up a bridged network with dynamic IP allocation, accessing the VM via SSH clients like MobaXterm and PuTTY, and configuring a static IP address for the VM. If you prefer a video tutorial, check out this YouTube video for step-by-step guidance.


1. Set Up a Bridged Network for Dynamic IP

  1. Open Oracle VirtualBox and select your Linux 7 VM.
  2. Go to the Settings menu.
  3. Navigate to the Network tab.
  4. In Adapter 1, select Bridged Adapter from the “Attached to” dropdown.
  5. Select your active network adapter (e.g., Wi-Fi or Ethernet) from the “Name” dropdown.
  6. Click OK to save the changes.

This setup allows the VM to share the host’s network connection, providing internet access and enabling communication within the same local network.


2. Assign a Dynamic IP Address

  1. Boot up your Linux 7 VM.
  2. Log in to your VM and check that networking is enabled. Use the following command to confirm the network interface is up:
    nmcli connection show
    
  3. If networking is disabled, enable it:
    nmcli connection up <connection_name>
    

    Replace <connection_name> with your active network connection name.

  4. Ensure that the network adapter is set to acquire an IP address dynamically via DHCP:
    sudo dhclient
    
  5. Confirm the assigned IP address:
    ip addr
    

    Note down the dynamic IP address assigned to your VM.


3. Access the VM Using SSH Clients

With the VM’s dynamic IP address:

  1. Open MobaXterm or PuTTY on your host machine.
  2. Enter the dynamic IP address in the “Host” field.
  3. Use the default SSH port (22) and click Open or Start Session.
  4. Log in with your Linux VM username and password.

You should now have remote access to your VM.

 


4. Assign a Static IP Address

To assign a static IP address, follow these steps:

  1. Find Your Default Gateway:
    • On your host machine (Windows), open the Command Prompt and run:
      ipconfig
      
    • Note the “Default Gateway” under your active network adapter.
  2. Configure Static IP on the VM:
    • Open a terminal on your Linux 7 VM.
    • Edit the network configuration file for your adapter (e.g., ifcfg-enp0s3):
      sudo vim /etc/sysconfig/network-scripts/ifcfg-enp0s3
      
    • Modify the file to include the following:
      BOOTPROTO=static
      IPADDR=<your_static_ip>
      NETMASK=255.255.255.0
      GATEWAY=<default_gateway>
      DNS1=8.8.8.8
      DNS2=8.8.4.4
      

      Replace <your_static_ip> with an unused IP address in your network and <default_gateway> with the gateway address you found earlier.

    • Save the file and exit the editor.
  3. Restart the Network Service:
    sudo systemctl restart network
    
  4. Verify the static IP configuration:
    ip addr
    ping google.com
    

5. Test Static IP Access

  1. Open MobaXterm or PuTTY on your host machine.
  2. Enter the static IP address in the “Host” field.
  3. Use the default SSH port (22) and click Open or Start Session.
  4. Log in with your Linux VM credentials.

You should now be able to access your VM using the static IP address.


Conclusion

By following the above steps, you can configure networking for your Linux 7 VM in Oracle VirtualBox, providing both dynamic and static IP connectivity. This setup ensures seamless internet access, local network communication, and reliable remote access via SSH clients like MobaXterm and PuTTY. For a visual walkthrough, watch the YouTube video tutorial.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *