Score:0

Can't get website running in virtual machine to display in browser, networking confusion

tz flag

This is a question about networking in Ubuntu I suppose, but requires some background.

I am a Linux novice. I have a Trellis Wordpress site I've taken over, so set up a dual-boot laptop with Ubuntu 18.04 (version required by the setup/environment). I followed the previous developer's instructions to setup the environment, clone the project, then enter the trellis folder and do a vagrant up.

This all works, I get this:

  ==> default: Machine 'default' has a post vagrant up message. This is a message
  ==> default: from the creator of the Vagrantfile, and not from Vagrant itself:
  ==> default: 
  ==> default: Your Trellis Vagrant box is ready to use!
  ==> default: * Composer and WP-CLI commands need to be run on the virtual machine
  ==> default:   for any post-provision modifications.
  ==> default: * You can SSH into the machine with vagrant ssh.
  ==> default: * Then navigate to your WordPress sites at /srv/www
  ==> default:   or to your Trellis files at /home/vagrant/trellis.
  ubuntu@ubuntu-laptop:~/uweek-cms/trellis$

I should then (by the notes) be able to use a local browser to navigate to the website: http://uweekdev.abaso.co.uk/

But that doesn't work, Chrome (and Firefox) report:

  This site can’t be reached
  uweekdev.abaso.co.uk refused to connect.

So Trellis has inserted a line in the hosts file: cat /etc/hosts reads:

  ## vagrant-hostmanager-start id: 16ff5846-31d4-4402-aa91-479139d39183
  192.168.50.5  uweekdev.abaso.co.uk
  ## vagrant-hostmanager-end

The previous developer talked about about network adaptors during installation of Ubuntu itself, but in the context of it being installed virtually, but as the docs were written for both ubuntu as an OS, and using VirtualBox on Windows, so I'm not sure if I've missed a step!

Here's ifconfig's output on the HOST machine:

## vagrant-hostmanager-start id: 16ff5846-31d4-4402-aa91-479139d39183
192.168.50.5    uweekdev.abaso.co.uk

## vagrant-hostmanager-end
  ubuntu@ubuntu-laptop:~/uweek-cms/trellis$ ifconfig
  enp1s0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 54:e1:ad:8e:30:09  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 4190  bytes 612036 (612.0 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4190  bytes 612036 (612.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  vboxnet0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.50.1  netmask 255.255.255.0  broadcast 192.168.50.255
        inet6 fe80::800:27ff:fe00:0  prefixlen 64  scopeid 0x20<link>
        ether 0a:00:27:00:00:00  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 78  bytes 9312 (9.3 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  wlp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.12  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::ebb5:652:1251:6b01  prefixlen 64  scopeid 0x20<link>
        ether 44:03:2c:4b:d6:88  txqueuelen 1000  (Ethernet)
        RX packets 3300  bytes 2803503 (2.8 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2431  bytes 462691 (462.6 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  ubuntu@ubuntu-laptop:~/uweek-cms/trellis$ ifconfig -s -a
  Iface      MTU    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
  enp1s0    1500        0      0      0 0             0      0      0      0 BMU
  lo       65536     4204      0      0 0          4204      0      0      0 LRU
  vboxnet0  1500        0      0      0 0            90      0      0      0 BMRU
  wlp2s0    1500     3526      0      0 0          2712      0      0      0 BMRU

And here it is when I vagrant ssh into the client virtual machine:

eth0: 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:fed2:10a5  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:d2:10:a5  txqueuelen 1000  (Ethernet)
        RX packets 2844  bytes 315692 (315.6 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2184  bytes 341128 (341.1 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.50.5  netmask 255.255.255.0  broadcast 192.168.50.255
        inet6 fe80::a00:27ff:fe34:19a5  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:34:19:a5  txqueuelen 1000  (Ethernet)
        RX packets 96  bytes 7852 (7.8 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 113  bytes 8864 (8.8 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 22  bytes 1824 (1.8 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 22  bytes 1824 (1.8 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Now I confess I'm lost. I don't understand any of the networking side of this and I'm not sure how to progress to get the website running in the virtual machine to load in my browser!

Any ideas what to do to troubleshoot/try/check?

Many thanks for helping out an enthusiastic novice.

Score:1
in flag

You will want to edit your /etc/hosts file, as the IP address does not match the one reported by your virtual machine.

In /etc/hosts, change:

192.168.50.5  uweekdev.abaso.co.uk

to:

192.168.50.1  uweekdev.abaso.co.uk

Save the file and, if needs be, clear your browser cache to force it to look up the domain again. This should resolve your issue


One item to look at is whether VirtualBox is configured to allow network traffic in to the VM or not. You can find this in the "Network Settings" bit of the VM configuration:

VirtualBox — Network

You will want to confirm that the "Promiscuous Mode" is set to "Allow All", otherwise VirtualBox will block traffic to the VM.

tz flag
Thanks @matigo. I edited the hosts and saved it, cleared my cache (I wiped everything from all time) and it still won't load!
in flag
Have you confirmed that the network adapter in VirtualBox has the "Promiscuous Mode" set to "Allow All"? This is found under "Advanced" in the network adapter settings.
tz flag
I'll check.....
tz flag
I can't figure out how to check or do this step :(
tz flag
One thing, whenever I vagrant halt and up again, it resets my hosts to 50.5. I noticed that if I vagrant ssh then the ifconfig shows: eth1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.50.5. I don't understand how the vbox 50.1 relates to the 50.5 :(
in flag
Was the `ifconfig` output from the host or the VM? If it was from the host, then you will want to confirm the IP on the client. Use `ip a` for this (as `ifconfig` is deprecated and going away). Then you can also confirm the VM's network settings. The answer has been updated with a screenshot showing what bit I'm referring to
tz flag
The ifconfig in the post was from the host (50.1) the ifconfig for the client is 50.5. ip a shows the same IPs on both. I checked in Vbox settings, Adaptor 1 is attached to NAT and has Promiscuous Allow All (greyed out), and Adaptor 2 is attached to Host-Only-Adaptor and I set that to Promiscuous Allow all. Restarted everything, no change :(
Score:0
tz flag

Well, after following the kind advice of @matigo I suppose I know a lot more about how Vagrant, VirtualBox and Ubuntu networking works!

Solution: I destroyed the vm with vagrant destroy, did an apt-get upgrade, rebooted and then ran the vagrant up again to recreate everything. The setup looked a little different, strangely, but this time at the end the browser URL worked.

Notes: I had tried a destroy and recreate earlier and it didn't have any effect. 'Promiscuous' is denied for both NAT and host-only adaptors in the vbox settings, and finally the hosts entry is the 50.5 as originally set.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.