Page 1 of 1

[WorksForMe] Unable to reach webserver inside Ubuntu 18.10 guest

Posted: 18. Dec 2018, 03:05
by ApoloDuvalis
I have got a Django server running inside an Ubuntu 18.10 server guest VM but despite everything seems ok, I keep getting a "This site can’t be reached" error message on my host's browser.

My VirtualBox settings are:
Host Network Manager: vboxnet0
  • address 192.168.99.1
    mask 255.255.255.0
    DHCP Server: disabled
VM Settings:
Adapter 1:
  • Attached to: NAT
    Adapter type: Intel PRO/1000 MT Desktop
    Promiscuous Mode: Deny
    Port forwarding:
    • WEB / TCP / host port: 8001 / guest port: 8000
      SHH / TCP / host port: 2281 / guest port: 22
Adapter 2:
  • Attached to: Host-only Adapter
    Name: vboxnet0
    Adapter type: Intel PRO/1000 MT Desktop
    Promiscuous Mode: Deny
My host's setup:
MacOS High Sierra (10.13.6)
VirtualBox 5.2.22

Code: Select all

vboxnet0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> mtu 1500
	ether 0a:00:27:00:00:00 
	inet [b]192.168.99.1[/b] netmask 0xffffff00 broadcast 192.168.99.255
My guest's setup:
Ubuntu 18.10 Server (I got a preinstalled VM from osboxes dot org/ubuntu-server)

Code: Select all

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::a00:27ff:fe89:cd75  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:89:cd:75  txqueuelen 1000  (Ethernet)
        RX packets 473  bytes 404614 (404.6 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 211  bytes 20490 (20.4 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s8: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether 08:00:27:1d:19:0c  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        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 104  bytes 7748 (7.7 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 104  bytes 7748 (7.7 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
The output of /Applications/VirtualBox.app/Contents/MacOS/VBoxManage list hostonlyifs:

Code: Select all

Name:            vboxnet0
GUID:            786f6276-656e-4074-8000-0a0027000000
DHCP:            Disabled
IPAddress:       192.168.99.1
NetworkMask:     255.255.255.0
IPV6Address:     
IPV6NetworkMaskPrefixLength: 0
HardwareAddress: 0a:00:27:00:00:00
MediumType:      Ethernet
Wireless:        No
Status:          Up
VBoxNetworkName: HostInterfaceNetworking-vboxnet0
From inside the guest everything is working as expected (ping outside machines, download packages, etc.).
From the host I am able to ssh into the guest using "ssh osboxes@192.168.99.1 -p 2281" that uses the port forwarding configured on the NAT adapter.

Any ideas? It's maybe a firewall issue? If so, how can I check it?
Thanks!

Re: Unable to reach webserver inside Ubuntu 18.10 guest

Posted: 18. Dec 2018, 04:37
by Martin
Something seems to be wrong here.
You shoudn't be able to reach the guest using port forwarding over the NAT adapter by using the IP address of the hostonly adapter.
Which IP address did you configure for the second / hostonly adapter inside the guest?
What is the normal IP address of your host on WLAN or Ehternet?

Re: Unable to reach webserver inside Ubuntu 18.10 guest

Posted: 18. Dec 2018, 17:11
by ApoloDuvalis
Do you mean enp0s8? As you can see on the ifconfig -a output, it has no static IP since I left it as it is configured by Ubuntu after booting with adapter 2 attached to host-only:

Code: Select all

enp0s8: flags=4098<BROADCAST,MULTICAST>  mtu 1500
        ether 08:00:27:1d:19:0c  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
Martin wrote:What is the normal IP address of your host on WLAN or Ehternet?
My host is connected through WiFi as 192.168.0.19:

Code: Select all

en1: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
	ether 7c:c3:a1:ad:ab:dc 
	inet6 fe80::c43:a226:2a19:67d4%en1 prefixlen 64 secured scopeid 0x7 
	inet 192.168.0.19 netmask 0xffffff00 broadcast 192.168.0.255
	nd6 options=201<PERFORMNUD,DAD>
	media: autoselect
	status: active
From inside the guest, it seems the guest as 10.0.2.2 (its gateway).

In theory, the configuration of both adapters on the VM should not require additional settings. The only thing remotely close to this issue has been addressed in other forums I have checked out by switching the order of the adapters: Host-only as Adapter 1 and NAT as Adapter 2. However that approach did not work in my case and the guest was not even able to turn up the network.

Re: Unable to reach webserver inside Ubuntu 18.10 guest

Posted: 18. Dec 2018, 17:20
by ApoloDuvalis
SOLVED!
It seems VirtualBox was working as expected and it was a Django issue: for the server to ve visible from outside the guest VM, the Django server needs to run explicitly with the guest's IP and port:

Code: Select all

python3 manage.py runserver 10.0.2.15:8000
So it can be reached from the host's browser as

Code: Select all

192.168.99.1:8001/

Re: Unable to reach webserver inside Ubuntu 18.10 guest

Posted: 20. Dec 2018, 02:09
by socratis
Glad you got it going. Marking as [WorksForMe].