VirtualBox guest does not receive IP address assigned by Vagrantfile

After the firewall has risen, the guest is assigned the wrong IP address and the following error is raised:

... ... SSH address: 127.0.0.1:2222 serverbox: SSH username: vagrant serverbox: SSH auth method: private key serverbox: Warning: Connection timeout. Retrying... serverbox: Warning: Connection timeout. Retrying... serverbox: Warning: Connection timeout. Retrying... ... 

I work at home and in the office, so I always have to reconfigure the IP address assignment in Vagrantfile depending on where I am, because the subnets are different. (192.168.xx vs 10.80.xx)

This works well until yesterday. I do not know what causes the problems, as I have not made any adjustments.

Vagrantfile:

 Vagrant.configure("2") do |config| config.vm.provider "virtualbox" do |vb| vb.customize ["modifyvm", :id, "--memory", "512"] end config.vm.network "public_network", ip: '10.80.2.144' #config.vm.network "public_netowrk", ip: '192.168.1.144' end ... 

Vagrantfile should put my address at 10.80.xx, but netstat shows that my field is still growing at 192.168.xx, which means that I can’t work with the mailbox because it is out of the subnet.

I made a stop and again, and also completely rebooted my processor and checked that virtualization was enabled in the BIOS.

I looked here and tried this method to no avail.

I also tried vb.gui = true, but my machine works without a head. The Virtualbox Preview logging screen may provide some useful information, but it is so small that I can do nothing. If anyone has any tips on how to do this more, that could probably help.

UPDATE:

So, my decision is an undesirable decision, but my working day was torpedoed and he needs to move forward so that I just destroy my box and rise again.

Apparently, my keys have become insecure. I don’t know how this happened, but a new box replaced my keys.

+6
source share
3 answers

my suggestion for your problem.

Run vagrant reload and vagrant provision on this instance after changing the IP.

If the problem persists, try the second one:

change public_network to private_network

 config.vm.network "private_network", ip: '10.80.2.144' #config.vm.network "private_network", ip: '192.168.1.144' 
+6
source

Just add two lines to Vagrantfile and a roaming reboot

 config.vm.network "forwarded_port", guest: 80, host: 8080, auto_correct: true config.vm.network "private_network", ip: "192.168.100.1", auto_config: false 

The problem of hope will be resolved.

+1
source

Note
This answer is not a solution to the problem. This can be useful when debugging problems when you cannot enter your stray box.

I have a problem:

  • Tramp 1.8.1
  • VirtualBox 5.0.12r104815
  • Vagrantfile option config.vm.network "private_network", ip: "10.50.50.3"

The following steps helped me solve my problem:

  • enabled the GUI in Vagrantfile by adding vb.gui = true
  • launched a virtual machine using vagrant up
  • used the VirtualBox terminal to log in (user: vagrant, password: vagrant)
  • checked interface ip address in devbox

     $ sudo ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}' 10.0.2.15 
  • checked the local VirtualBox interface (using ifconfig ):

     vboxnet8 Link encap:Ethernet HWaddr 0a:00:27:00:00:08 inet addr:10.50.50.1 Bcast:10.50.50.255 Mask:255.255.255.0 inet6 addr: fe80::800:27ff:fe00:8/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:258 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:0 (0.0 B) TX bytes:39147 (39.1 KB) 

I saw that the virtual IP address is not suitable for the vboxnet8 interface vboxnet8 host.

I tried rebooting the VM using vagrant reload , but without success. The only thing that helped me was to reboot the VM using vagrant destroy -f , vagrant up (see Additional comment below).


How could this happen? After booting the virtual machine for the first time, one of my initialization scripts changed /etc/ssh/sshd_config , which was subsequently invalid. Then the script restarted ssh, which caused a connection problem.

The tramp started the virtual machine, but I could not photograph it.

Then I had to change the private_network ip, which caused a strange situation.

In the end, when the actual /etc/ssh/sshd_config element fixed my problem again.

0
source

Source: https://habr.com/ru/post/980722/


All Articles