How to assign static IP to Ubuntu Server (VirtualBox)

Please see my setup here:

NAT is set up here:

enter image description here

Host-only adapter is enabled here:

enter image description here

network for virtual box is configured here:

enter image description here

then I set up interface on the server like this:

enter image description here

then I run sudo netplan apply and I should be all set. I can ping myself on the server:

enter image description here

but can't ping the server from my local computer:

enter image description here

Hence the network isn't actually connected to the Internet. What am I doing wrong here ?

update:

network connection is now set to "bridged":

enter image description here

8

1 Answer

The answer is Yes if you assign a static ip from your router for your virtual box virtual machine. (This need specific ip address from your local router).

The answer is No if you aren't assign a static ip from your router for your virtual box virtual machine.

If not how can we access the virtual machine via our laptop terminal ?

This is the method how to do that !

Keep in mind this is temporary method and all settings are reset after you restart the virtual machine . This will also enable internet access on your virtual box sever.

According to your question ,

First configure NAT (Network Address Translation) setting for Network Adapter 1

NAT Configuration

Then configure Host-only Adapter setting for Network Adapter 2

Host-only Adapter configuration

After that manual IP address assignment

Manual ip address assignment

Here don't enable the DHCP server as below

enter image description here

These are the settings for your server virtual machine hardware (assume that your are using a Ubuntu server virtual machine) !

After that install the Ubuntu server on the virtual hard disk ...

After you log on to the Ubuntu server (i think you provided administrative credentials ) , you have to do the followings.

First issue the following command to see the ip settings assigned for network adapters on the virtual Ubuntu server

 ubuntu@vagrant:~$ ifconfig

On my test server there are eth0 , eth1 network interface cards , I have selected eth1 for this because eth0 is already assigned with an ip address by system default.

On Ubuntu server switch to the root user as ,

 ubuntu@vagrant:~$ sudo -i

Then the appear root user prompt as below ,

 root@vagrant:~#

Then issue the following command

 root@vagrant:~# ifconfig eth1 192.168.188.101 netmask 255.255.255.0

Once you done this exit from the root user by typing exit

Here don't turn off the virtual machine !

Then minimize the virtual machine and fireup a local terminal

After that issue ifconfig on the local terminal . Here you can see the various network adapters including the host only adaptor.

Then try to ping the ip address of the virtual machine as below

user@user-laptop:~$ ping 192.168.188.101

If this ping is success you can now ssh to the your virtual Ubuntu server as below

user@user-laptop:~ ssh ubuntu@192.168.188.101

Here you can provide the virtual server password .

So I think this method is worked for you if you are interested .

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like