Beruflich Dokumente
Kultur Dokumente
VIRTUALIZATION 54
Download Your Free eBooks NOW - 10 Free Linux eBooks for Administrators | 4 Free Shell Scripting eBooks
Once you have installed different operating systems inOracle 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.
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 usingNAT via the host machine.
Important: Always set the first adapter to communicate with the host and the second adapter to connect to the Internet.
From the following interface, there are two options; chooseHost-only Networks by clicking on it. Then use the + sign on the right to add a new host-only
network.
Below is a screen shot showing a new host-only network has been created calledvboxnet0.
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 theedit 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
In the next interface, you can configure theDHCP 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
Back at the virtual box manager interface, select your guest virtual machine such asUbuntu 16.10 server or CentOS 7 and click on the Settings menu.
Configure VM Settings
$ ip add
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 interfaceenp0s3 (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
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
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):
$ ip add
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.
SHARE
+ +
If You Appreciate What We Do Here On TecMint, You Should Consider:
1. Stay Connected to: Twitter | Facebook | Google Plus
Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.
NEXT STORY
PREVIOUS STORY
bmon – A Powerful Network Bandwidth Monitoring and Debugging Tool for Linux
How to Install, Run and Delete Applications inside Docker Containers – Managing XenServer with a XenCenter and Xen Orchestra Web Interfaces
Part 2 – Part – 7
54 RESPONSES
Comments 6 Pingbacks 0
Then, go into the VM’s Network Settings and you can choose the newly created Host Only network there. This may be what the first section in
this article “Create a Network For Guests and Host Machine” was trying to do, but the UI has changed so much I found it impossible to follow.
Reply
I do not see ifcfg-enp0s8 file in network-scripts location and unlike in your screenshots, I have no IP address forenp0s3 & enp0s8 attached
but virbr0 has IP. ( Is that default?)
I wonder which file to update now for static IP configuration to connect from win10 through Putty?
Which distro are you using? Use the appropriate file for your distro, it could be different from what is in the screenshot.
Reply
« Older Comments
Comment
Name * Email *
Website
Notify me of followup comments via e-mail. You can alsosubscribe without commenting.
Post Comment
This site uses Akismet to reduce spam. Learn how your comment data is processed .
I TecMint :
How to Add Linux Host to Nagios Monitoring Server Using NRPE Plugin
BRUCE SAYS:
I see a lot of recommendations for Gparted. And it makes...
Linux System Administrator Bundle with 7-Courses (96% off)
LINUX EBOOKS
Never Miss Any Linux Tutorials, Guides, Tips and Free eBooks
Join Our Community Of 150,000+ Linux Lovers and get a weekly newsletter in your inbox
YES! SIGN ME UP
LINUX MONITORING TOOLS
bmon – A Powerful Network Bandwidth Monitoring and Debugging Tool for Linux
Web VMStat: A Real Time System Statistics (Memory, CPU, Processess, etc) Monitoring Tool for Linux
9 Best Twitter Clients for Linux That You Will Love to Use
Tecmint: Linux Howtos, Tutorials & Guides © 2019. All Rights Reserved.
The material in this site cannot be republished either online or offline, without our permission.