Search code examples
ubuntuvagrantvirtualbox

Vagrant public network unreachable


EDIT: Nevermind, it's a subnet issue. The default for a local network is 192.168.0.X. Anything else has to be set up first.

Host: Ubuntu 18.04

Vagrant 2.2.7, Virtualbox 6.1

What I'm trying to achieve: a VM running on a separate laptop(to not use hardware of main laptop) and being able to contact it from another machine, at home.

At this point, I can't even access the ip address locally. I can SSH into the machine though.

My Vagrantfile, using a predefined box(originally bionic64):

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "mybox"

  config.vm.network "public_network", ip: "192.168.67.42"

  config.vm.box_check_update = false

  config.vm.provider "virtualbox" do |vb|
    # Display the VirtualBox GUI when booting the machine
    vb.gui = false

    # Customize the amount of memory on the VM:
    vb.memory = "4096"

    # Customize the amount of cpus for the VM:
    vb.cpus = "2"
  end

end

This seems to create eth1 and it looks like this:

ip a show eth1
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 08:00:27:06:43:d5 brd ff:ff:ff:ff:ff:ff
    inet 192.168.67.42/24 brd 192.168.67.255 scope global eth1
       valid_lft forever preferred_lft forever
    inet6 2a02:1812:1404:2200:a00:27ff:fe06:43d5/64 scope global dynamic mngtmpaddr noprefixroute 
       valid_lft 231996sec preferred_lft 59196sec
    inet6 fe80::a00:27ff:fe06:43d5/64 scope link 
       valid_lft forever preferred_lft forever

Routes:

default via 10.0.2.2 dev eth0 proto dhcp src 10.0.2.15 metric 100 
10.0.2.0/24 dev eth0 proto kernel scope link src 10.0.2.15 
10.0.2.2 dev eth0 proto dhcp scope link src 10.0.2.15 metric 100 
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 
192.168.67.0/24 dev eth1 proto kernel scope link src 192.168.67.42

Yes, I checked all the other answers here. Non of it worked for me.

Ping says "Destination Host Unreachable".

The ip address is just something random I thought of.


Solution

  • Nevermind, it's a subnet issue. The default for a local network is 192.168.0.X. Anything else has to be set up first.