1

So I created in my host machine (Ubuntu 17.10) a virtual machine with VirtualBox + Vagrant + Ansible.

Vagrant.configure("2") do |config|

  config.vm.box = "centos-7.3-x86_64_latest.box"
  config.vm.box_url = "http://nas.my-compamy.intern/centos-7.3-x86_64_latest.box"

  config.vm.hostname = "login.my-cloud.dev"
  config.vm.network "private_network", ip: "192.168.33.240"

  # enable to use synced folders
  # config.vm.synced_folder "/my/local/path", "/var/www/cce_login", disabled: true

  config.ssh.forward_agent = true
  config.ssh.keep_alive = true
  config.ssh.username = "vagrant"
  config.ssh.password = "vagrant"

  config.vm.provider :virtualbox do |v|
    # workaround as some virtualbox version seem to disconnect the NAT adapter
    v.customize ['modifyvm', :id, '--cableconnected1', 'on']

    v.memory = 1024
    v.cpus = 2
    v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
    v.customize ["modifyvm", :id, "--name", "login.cce-cloud.dev"]
    v.customize ["modifyvm", :id, "--accelerate3d", "off"]
    v.customize ["modifyvm", :id, "--accelerate2dvideo", "off"]
    v.customize ["modifyvm", :id, "--cpuexecutioncap", "75"]
    v.customize ["modifyvm", :id, "--largepages", "on"]
  end

  config.vm.provision "ansible" do |ansible|
    ansible.playbook = "ansible/site.yml"
    ansible.verbose = "vvv"
  end

end

I bring this machine up via

$ vagrant up --provision

After all this is done, I can log into SSH via Vagrant like this.

$ vagrant ssh

but when I want to use it from MySQL Workbench, FTP access, or direct SSH, I get an error. I cant even ping the machine.

$ ping 192.168.33.240

PING 192.168.33.240 (192.168.33.240) 56(84) bytes of data.
From 192.168.33.1 icmp_seq=1 Destination Host Unreachable
From 192.168.33.1 icmp_seq=2 Destination Host Unreachable
From 192.168.33.1 icmp_seq=3 Destination Host Unreachable

Since I do not have permission to change the Vagrantfile from the DevOps team, I figured the error must be somewhere in how my host machine is configured, but I cannot seem to see what the problem is.

$ ifconfig 

enxdc9b9cee07b2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.111.198  netmask 255.255.255.0  broadcast 192.168.111.255
        inet6 fe80::f0ad:1d52:8e55:7fc7  prefixlen 64  scopeid 0x20<link>
        ether dc:9b:9c:ee:07:b2  txqueuelen 1000  (Ethernet)
        RX packets 11159  bytes 4878538 (4.8 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 8289  bytes 2106425 (2.1 MB)
        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 1607  bytes 173261 (173.2 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1607  bytes 173261 (173.2 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

vboxnet0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.33.1  netmask 255.255.255.0  broadcast 192.168.33.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 170  bytes 18067 (18.0 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

How could I change the configuration of my host OS, so that it reaches the virtual one?

Note: The enxdc9b9cee07b2 is my wired connection. I know it usually is eth0 but I am using an adapter for a USB port

Update

More info

enter image description here

enter image description here

enter image description here

0

The only network configurations that allow Host to VM communication is Host Only and Bridged modes. There is a table here that shows the different network types and if it can access the host, other VMs, internet, etc. Only bridged mode gets you full network access but typically pulls an IP from your DHCP, which you probably don't want in this situation.

You can get around this by having 2 networks to fulfill your needs, NAT and Host Only.

  • I do have this 2 networks and it is still not working – Enrique Moreno Tent Apr 19 '18 at 17:13
  • can you post the network config for the VM? – rtaft Apr 19 '18 at 17:29
  • The network configuration is set on the Vagrantfile I posted. is there something missing? – Enrique Moreno Tent Apr 20 '18 at 7:18
  • I was mainly looking to verify if what you have in Vagrant produced the results you are expecting. I only see one network configuration in the Vagrant file, but you said there are two...so I wanted to see that there really are two. I only see NAT in the config, and that does not allow host to VM communication. – rtaft Apr 20 '18 at 13:01
  • You are right. I updated the question. – Enrique Moreno Tent Apr 20 '18 at 13:15
0

I found in the end the solution myself.

Apparently the version that comes pre-installed with Ubuntu is not the official DEB from oracle.

What I did is to save my virtual machines in a temp backup folder, then delete Vagrant and Virtualbox, and then download the official deb from their website.

Once I started the machines, they were working without any problem.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.