Skip to content



Download 19.29 Kb.
Date14.06.2022
Size19.29 Kb.
#58986
q2

صصصصصصصصصصصصصصصصصصص
ثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثث
ثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثثث
Skip to content
Linux Foundation LFCS and LFCE Certification Preparation Guide - Get This Book
Home
About
eBooks
Shop
Donate
Linux Online Courses
Subscribe to Newsletter
Linux Hosting
A-Z Linux Commands
Get Involved

AD
Tecmint: Linux Howtos, Tutorials & Guides


Linux Distro’s
FAQ’s
Programming
Linux Commands
Linux Tricks
Best Linux Tools
Certifications
Guides
Monitoring Tools
How to Configure Network Between Guest VM and Host in Oracle VirtualBox
Aaron KiliFebruary 4, 2017 CategoriesVirtualization 65 Comments

AD
Once you have installed different operating systems in Oracle VirtualBox, you may want to enable communication between the host and the virtual machines.

In this article, we will describe the simplest and direct method of setting up a network for guest virtual machines and the host in Linux.

For the purpose of this tutorial:

Host Operating System – Linux Mint 18
Virtual Machine OS – CentOS 7 and Ubuntu 16.10
Requirements
A working Oracle Virtualbox installed on Host machine.
You must have installed a guest operating system such as Ubuntu, Fedora, CentOS, Linux Mint or any of your choice in the Oracle virtual box.
Power off the virtual machines as you perform the configurations up to the step where your required to turn them on.
In order for the guest and host machines to communicate, they need to be on the same network and by default, you can attach up to four network cards to your guest machines.

The default network card (Adapter 1) is normally used to connect the guest machines to the Internet using NAT via the host machine.


AD
Important: Always set the first adapter to communicate with the host and the second adapter to connect to the Internet.

Create a Network For Guests and Host Machine
At the Virtualbox manager interface below, start by creating a network on which the host and guests will operate.

Go to File –> Preferences or hit Ctrl + G:

Virtualbox Preferences Window
Virtualbox Preferences Window
From the following interface, there are two options; choose Host-only Networks by clicking on it. Then use the + sign on the right to add a new host-only network.

Set Guest Network


Set Guest Network
Below is a screen shot showing a new host-only network has been created called vboxnet0.

Virtualbox Preferences Window


Virtualbox Preferences Window
If you want, you can remove it by using the - button in the middle and to view the network details/settings, click on the edit button.

You can as well change the values as per your preferences, such as the network address, network mask, etc.

Note: The IPv4 address in the interface below is the IP address of your host machine.

Host Network Details


Host Network Details
In the next interface, you can configure the DHCP server that is if you want the guest machines to use a dynamic IP address (make sure it is enabled before using it). But I recommend using a static IP address for the virtual machines.

Now click OK on all network settings interfaces below to save the changes.

Set Guest Static IP aAddress
Set Guest Static IP aAddress
Configure Virtual Machine Network Settings
Note: You can follow the steps below for every virtual machine that you want to add on the network to communicate with the host machine.

Back at the virtual box manager interface, select your guest virtual machine such as Ubuntu 16.10 server or CentOS 7 and click on the Settings menu.

Configure VM Settings
Configure VM Settings
Configure Adapter to Connect Virtual Machine to Host
Choose the Network option from the interface above. Afterwards, configure first network card (Adapter 1) with the following settings:

Check the option: “Enable Network Adapter” to turn it on.


In the field Attached to: select Host-only Adapter
Then select the Name of the network: vboxnet0
As in the screen shot below and click OK to save the settings:

Enable Network Adapter for Guest VM


Enable Network Adapter for Guest VM
Configure Adapter to Connect Virtual Machine to Internet
Then add a second network card (Adapter 2) to connect virtual machine to the Internet via the host. Use the settings below:

Check the option: “Enable Network Adapter” to activate it.


In the field Attached to: select NAT
Enable Network Adapter for VM
Enable Network Adapter for VM
Setup Static IP Address for Guest Virtual Machine
At this stage, power on the guest virtual machine, login and configure static IP address. Run the command below to show all the interfaces on the guest machine and allocated IP addresses:

$ ip add
Configure Static IP Address for VM


Configure Static IP Address for VM
From the screen shot above, you can see that there are three interfaces enabled on the virtual machine:

lo – loopback interface


enp0s3 (Adapter 1) – for host-only communication which is using the DHCP as set in one of the previous steps and later configured with a static IP address.
enp0s8 (Adapter 2) – for connection to the Internet. It will use DHCP by default.
On Debian/Ubuntu/Linux Mint
Important: Here, I used Ubuntu 16.10 Server: IP address: 192.168.56.5.

Open the file /etc/network/interfaces using your favorite editor with super user privileges:

$ sudo vi /etc/network/interfaces
Use the following settings for the interface enp0s3 (use your preferred values here):

auto enp0s3


iface enp0s3 inet static
address 192.168.56.5
network 192.168.56.0
netmask 255.255.255.0
gateway 192.168.56.1
dns-nameservers 8.8.8.8 192.168.56.1
Save the file and exit.

Then restart network services like so:

$ sudo systemctl restart networking
Alternatively, reboot the system and closely, check if the interface is using the new ip addresses:

$ ip add
On RHEL/CentOS/Fedora


Important: For this section, I used CentOS 7: IP address: 192.168.56.10.

Begin by opening the file for enp0s3 – host-only network interface; /etc/sysconfig/network-scripts/ifcfg-enp0s3 using your favorite editor with super user privileges:

$ sudo vi /etc/sysconfig/network-scripts/ifcfg-enp0s3
Create/modify the following settings (use your preferred values here):

BOOTPROTO=static


ONBOOT=yes
IPADDR=192.168.56.10
NETWORK=192.168.56.0
NETMASK=255.255.255.0
GATEWAY=192.168.56.1
DNS=8.8.8.8 192.168.56.1
NM_CONTROLLED=no #use this file not network manager to manage interface
Save the file and exit. Then restart network service as follows (you can as well reboot):

$ sudo systemctl restart network.service


Check if the interface is using the new IP addresses as follows:

$ ip add
Manage Virtual Machines From Host Using SSH


On the host machine, use SSH to manage your virtual machines. In the following example, am accessing the CentOS 7 (192.168.56.10)server using SSH:

$ ssh tecmint@192.168.56.10


$ who
Connect Guest VM using SSH
Connect Guest VM using SSH
That’s it! In this post, we described a straightforward method of setting up a network between a guest virtual machines and the host. Do share your thoughts about this tutorial using the feedback section below.

TagsOracle Virtualbox


Post navigation
bmon – A Powerful Network Bandwidth Monitoring and Debugging Tool for Linux
How to Check Remote Ports are Reachable Using ‘nc’ Command
If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

AD
If You Appreciate What We Do Here On TecMint, You Should Consider:


TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

Related Posts
Install LXC Linux Containers in Ubuntu
How to Install, Create and Manage LXC (Linux Containers) in Ubuntu/Debian

Migrate Virtualbox VMs Into KVM VMs


How to Use Virtualbox VMs on KVM In Linux

Control Panels to Manage Virtual Machines


10 Open Source/Commercial Control Panels For Virtual Machines (VM’s) Management

Build Configure Docker Images with Dockerfile


How to Automatically Build and Configure Custom Docker Images with Dockerfile – Part 3

Install and Run Applications in Docker Containers


How to Install, Run and Delete Applications Inside Docker Containers – Part 2

Install Docker and Learn Basic Container Manipulation


Install Docker and Learn Basic Container Manipulation in CentOS and RHEL 8/7 – Part 1

65 thoughts on “How to Configure Network Between Guest VM and Host in Oracle VirtualBox”


Comment navigation
Older Comments

Nazneen Malik


April 29, 2021 at 8:12 pm
This needs me to first create the host network manager: File » Host Network Manager » Create.

Reply
Comment navigation


← Older Comments
Got something to say? Join the discussion.
Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.

Comment
Name


Name *
Email
Email *
Save my name, email, and website in this browser for the next time I comment.

AD
Over 3,500,000+ Readers

Join TecMint on Facebook Follow TecMint on Twitter Join TecMint on LinkedIn Follow TecMint on Instagram Follow TecMint via RSS Feed Subscribe to TecMint Newsletter
A Beginners Guide To Learn Linux for Free [with Examples]

AD
Red Hat RHCSA/RHCE 8 Certification Study Guide [eBooks]


Linux Foundation LFCS and LFCE Certification Study Guide [eBooks]
Learn Linux Commands and Tools
Find Top Running Processes by Highest Memory and CPU Usage in Linux

Learn How to Generate and Verify Files with MD5 Checksum in Linux

Useful ‘host’ Command Examples for Querying DNS Lookups

Understanding Shutdown, Poweroff, Halt and Reboot Commands in Linux

3 Command Line Tools to Install Local Debian (.DEB) Packages

Nix – The Purely Functional Package Manager for Linux

Join TecMint Weekly Newsletter
If You Appreciate What We Do Here On TecMint, You Should Consider:

Support Us


AD

AD


Linux Server Monitoring Tools
iftop – A Real Time Linux Network Bandwidth Monitoring Tool

VnStat PHP: A Web Based Interface for Monitoring Network Bandwidth Usage

How to Test Network Throughput Using iperf3 Tool in Linux

How to Install htop on CentOS 8

Cockpit – A Powerful Tool to Monitor and Administer Multiple Linux Servers via Browser

How to Monitor User Activity with psacct or acct Tools

Learn Linux Tricks & Tips
Add Rainbow Colors to Linux Command Output in Slow Motion

How to Convert Files to UTF-8 Encoding in Linux

vlock – A Smart Way to Lock User Virtual Console or Terminal in Linux

How to Set Limits on User Running Processes in Linux

mimipenguin – Dump Login Passwords From Current Linux Users

How to Monitor Progress of (Copy/Backup/Compress) Data using ‘pv’ Command

Best Linux Tools
Best PDF Editors to Edit PDF Documents in Linux

10 Best Markdown Editors for Linux

16 Best Web Browsers I Discovered for Linux in 2020

Top 27 Tools for VMware Administrators

13 Best Tiling Window Managers for Linux

3 Useful GUI and Terminal Based Linux Disk Scanning Tools

Donate to TecMintContact UsAdvertise on TecMintLinux ServicesCopyright PolicyPrivacy PolicyCareerSponsored Post
Tecmint: Linux Howtos, Tutorials & Guides © 2022. All Rights Reserved.
The material in this site cannot be republished either online or offline, without our permission.

Hosting Sponsored by : Linode Cloud Hosting



Scroll back to top
Download 19.29 Kb.

Share with your friends:




The database is protected by copyright ©ininet.org 2024
send message

    Main page