Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

Public Network não pega IP

Galera, Vi que um monte de gente aqui está tendo o mesmo problema que eu, mas também não vi alguém que conseguiu sair dessa. Vou colocar meu vangrantfile e o log aqui e, se alguém puder ajudar, agradeço. Ah! Não sei se faz diferença, mas estou usando MacOS Monterrey e Virtual Box 6.1 no meu projeto.

Segue:

Vangrantfile

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/bionic64"
  #Configure portforward for Nginx server in localhost
  config.vm.network "forwarded_port", guest: 80, host: 8080

  #Configute public networks
  config.vm.network "public_network", bridge: "en1: Wi-Fi"
end

Log ao rodar o %vangrant up

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'ubuntu/bionic64' version '20220325.0.0' is up to date...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: bridged
==> default: Forwarding ports...
    default: 80 (guest) => 8080 (host) (adapter 1)
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default: 
    default: Guest Additions Version: 5.2.42
    default: VirtualBox Version: 6.1
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => /Users/cleberlopes/Documents/Devops/bionic
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.

Agradeço desde já a ajuda, galera!

1 resposta
solução!

Pessoal,

Lendo um pouco acabei descobrindo o que estava acontecendo e vou explicar aqui para quem passar pelo mesmo problema ter como se guiar, ok?

Como eu disse, eu estava com o Virtual Box 6.1, mas o plugin do Vangrant era para a versão 5.2.42, o que se vê nesse trecho, bem no final do log:

default: 
    default: Guest Additions Version: 5.2.42
    default: VirtualBox Version: 6.1

Fuçando a internet eu cheguei na documentação onde ensina a fazer um upgrade dessa versão do Guest Additions Version com esse comando:

vagrant plugin update vagrant-vbguest

Ele baixou alguns plugins e fez um apgrade do kernel do Linux para que tudo rodasse bem. Ao entrar por SSH na VM pude confirmar que a rede estava setada direitinho, conforme demonstrado aqui:

Welcome to Ubuntu 18.04.6 LTS (GNU/Linux 4.15.0-173-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Mon Apr  4 21:30:18 UTC 2022

  System load:  0.1               Processes:             105
  Usage of /:   3.8% of 38.71GB   Users logged in:       0
  Memory usage: 13%               IP address for enp0s3: 10.0.2.15
  Swap usage:   0%                IP address for enp0s8: 192.168.0.101


18 updates can be applied immediately.
17 of these updates are standard security updates.
To see these additional updates run: apt list --upgradable

New release '20.04.4 LTS' available.
Run 'do-release-upgrade' to upgrade to it.


Last login: Mon Apr  4 21:23:15 2022 from 10.0.2.2
vagrant@ubuntu-bionic:~$ 

Aí, para o Vangrant não ficar me enchendo a paciência, perguntando em qual interface ele deveria fazer o bridge toda vez que eu desse um % vagrant up , eu alterei meu Vangrantfile para ficar dessa forma:

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/bionic64"
  #Configure portforward for Nginx server in localhost
  config.vm.network "forwarded_port", guest: 80, host: 8080

  #Configure public networks
  config.vm.network "public_network", ip: "192.168.0.101", bridge: "en1: Wi-Fi"
end

Lembre-se de trocar o que está em bridge: "en1: Wi-Fi" para se adequar a a interface que sua máquina usa para pegar internet, ok? Vc pode ver isso com o comando ifconfig (Linux e Mac) ou ipconfig (Windows e alguns Linux)

Espero que ajude!