0

I am trying to setup a test web server My machine is a windows 10 I installed virtualbox -> then ubuntu -> mysql -> apache2 -> php

I am able to test like this in my ubuntu http://localhost/info.php -> working

I am not sure how to connect from my windows box to my web server on ubuntu. Thanks so much for helping me

cat interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
#iface lo inet loopback
iface lo inet static
address 192.168.1.1
netmask 255.255.255.0
gateway 192.168.1.1


*ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.2.15  netmask 255.255.255.0  broadcast 10.0.2.255
        inet6 fe80::55d:fcc7:9636:c597  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:8d:b4:be  txqueuelen 1000  (Ethernet)
        RX packets 10205  bytes 10467155 (10.4 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 3596  bytes 442501 (442.5 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 464  bytes 63031 (63.0 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 464  bytes 63031 (63.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0*
Panther
  • 104,528
Khoa Nguyen
  • 1
  • 1
  • 1

1 Answers1

2

As your output indicates, you have only one interface which is set to use NAT.

To be able to send request from your host to your Ubuntu, you should create a Host-only network, and a new interface for your VM, then attach your VM to this network which your host is sitting on it too.


Create a host-only network:

In VirtualBox from file menu select preferences and in VirtualBox Preferences window, select Network, then host only networks.

After all by clicking on + plus sign add a new host-only network. it's name should be vboxnet0.


Run DHCP server

Then double click on it and go to DHCP tab to run a DHCP Server on this network, do your desired configuration as follow:

enter image description here


Create a new interface

Then you should add an interface to your Ubuntu VM and attach it to this network.

Do a right click on your Ubuntu VM, select settings, go to network section. Click on Adapter 2, check Enable Network Adapter and for Attached to select Host-Only adapter.

enter image description here

After all click ok to save these settings.

Now when you turn this VM on, you have a new interface, something like: enp0s9 which it should have an IP between 192.168.56.10 to 100, it should be 192.168.56.10. use ip a or ifconfig -a to find it out.


Config Apache

Now make apache to listen to this IP by changing apache configuration file to something like:

Listen 0.0.0.0:80

Or exactly your own IP, like:

Listen 192.168.56.10:80

Some part of this answer, and pictures are from my other answer related to VirtualBox from here.

Ravexina
  • 57,256