Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Static IP in VirtualBox Machine with Ubuntu 16.04 [closed]

I have installed Ubuntu Server 16.04 on a Virtual machine as a guest OS on my mac.

as always I have set it up with NAT and "Host Only" with the following configuration the way I had all my other VM Boxes with Ubuntu 14.04 to have static IP and Internet. but they seem not to work with the new Ubuntu. although "ifconfig" is giving me an OK result, I don't have Internet and I cannot reach my guest machine from my host machine with the mentioned IP.

my /etc/network/interfaces looks like this:

source /etc/network/interfaces.d/*
auto lo
iface lo inet loopback

auto enp0s3
iface enp0s3 inet static
address 192.168.56.106
netmask 255.255.255.0
dns-nameservers 8.8.8.8 8.8.4.4

and the result of "ifconfig -a" looks something like this:

enter image description here

any Idea why this is not working on Ubuntu 16.04 ?

Please note: I have restarted my network service(/etc/init.d/networking) and machine completely some hundred times.

like image 329
Amir Koklan Avatar asked Apr 25 '16 11:04

Amir Koklan


People also ask

How do I assign a static IP address to a VirtualBox virtual machine?

Launch your Windows virtual machine, click on Start > Command Prompt. Please put down the IP address, DNS server, and Default Gateway address. Click on Windows Start Menu > Control Panel > Network and Sharing Center. Click on the LAN connection and go to Properties.

How do I assign an IP address to a virtual machine in Linux VirtualBox?

Step 1: Select Global Settings from the File menu. Step 2: Select the Network item in the list on the left and then right-click on the tool icon. Step 3: The IP address for the host can now be changed in this host-only network. Step 4: After clicking on the DHCP Server tab, the DHCP server settings can be changed.

How do I find the IP address of a virtual machine in Ubuntu?

Open the Activities overview and start typing Settings. Click on Settings. Click on Network in the sidebar to open the panel. The IP address for a Wired connection will be displayed on the right along with some information.


1 Answers

I guess the problem was the new naming in Ubuntu 16.04. so I set my first Adapter to "Host-only Adapter" and second one to "NAT" and i could successfully get my IP set to "192.168.56.106" with following configuration. here is my /etc/network/interfaces :

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# Host Only Network
auto enp0s3
iface enp0s3 inet static
dns-nameservers 8.8.8.8 8.8.4.4
address 192.168.56.106
network 192.168.56.0
netmask 255.255.255.0
broadcast 192.168.56.255

# NAT Network
auto enp0s8
iface enp0s8 inet dhcp
like image 161
Amir Koklan Avatar answered Oct 14 '22 07:10

Amir Koklan