Vagrant: undo all changes made by setting static private ip - vagrant

Vagrant was running great for me and now vagrant up takes forever to boot up:
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: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
After about 30 of these messages and a few minutes later it finally goes through.
The only thing I changed was I set a private static ip address:
config.vm.network "private_network", ip: "192.168.33.10" in the Vagrant file.
I have since commented this line out of the vagrant file. How can I undo all changes that were made when I changed this setting? I have deleted the files in /var/lib/dhcp/ but this didn't seem to help.

Related

Vagrant up stuck

I'm running vagrant up and I'm facing an issue that it seemed to be this one at the beginning Vagrant stuck connection timeout retrying. I've tried all the solutions in there, I also did a vagrant destroy, but as soon as I do vagrant suspend, then the vagrant up command doesn't work, I have to quit and do vagrant reload to get the VM working. It's very annoying and frustrating.
I'm using vagrant homestead version 0.4.4 at the moment and a part of this issue everything works perfectly once the VM is started.
My current system is OSX El Captain.
Let me know if you need more details.
My Vagrantfile:
require 'json'
require 'yaml'
VAGRANTFILE_API_VERSION ||= "2"
confDir = $confDir ||= File.expand_path("vendor/laravel/homestead", File.dirname(__FILE__))
homesteadYamlPath = "Homestead.yaml"
homesteadJsonPath = "Homestead.json"
afterScriptPath = "after.sh"
aliasesPath = "aliases"
require File.expand_path(confDir + '/scripts/homestead.rb')
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
if File.exists? aliasesPath then
config.vm.provision "file", source: aliasesPath, destination: "~/.bash_aliases"
end
if File.exists? homesteadYamlPath then
Homestead.configure(config, YAML::load(File.read(homesteadYamlPath)))
elsif File.exists? homesteadJsonPath then
Homestead.configure(config, JSON.parse(File.read(homesteadJsonPath)))
end
if File.exists? afterScriptPath then
config.vm.provision "shell", path: afterScriptPath
end
end
Command up output when error:
~/Projects/credentialsApi (feature/10)$vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'laravel/homestead' is up to date...
==> default: A newer version of the box 'laravel/homestead' is available! You currently
==> default: have version '0.4.4'. The latest is version '0.5.0'. Run
==> default: `vagrant box update` to update.
==> default: Resuming suspended VM...
==> 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: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.
If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.
If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
~/Projects/credentialsApi (feature/10)$
vagrant ssh-config command output:
~/Projects/credentialsApi (development)$vagrant ssh-config
Host default
HostName 127.0.0.1
User vagrant
Port 2204
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile "/Users/pabloleone/Projects/credentialsApi/.vagrant/machines/default/virtualbox/private_key"
IdentitiesOnly yes
LogLevel FATAL
ForwardAgent yes
I finally fixed the issue. It was due to versions. I just upgraded vagrant and the VM.
First of all, try to run vagrant with VAGRANT_LOG=debug variable to debug the issue.
If that won't help, while it's showing you timeout messages, in another terminal run: vagrant status to see whether the VM is running correctly or not. Or run VirtualBox directly from GUI and check the machine state.
If it's running, check whether SSH credentials are correct, by the following command:
vagrant ssh-config
in order to:
check the hostname and port (e.g. 127.0.0.1:2222),
your private key (IdentityFile).
Also try logging in to the VM manually by:
vagrant ssh
or by this command (change default to proper host from above ssh-config command):
vagrant ssh-config > vagrant-ssh && ssh -F vagrant-ssh default
Since it works for you after vagrant reload (so your virtualization support in BIOS is likely enabled), possibly that your SSH server is not started by default on resume due to some issues. You should then check the SSH logs by fixing it via vagrant reload && vagrant ssh and check whether the logs by:
sudo tail /var/log/secure
If that's the case, for workaround to check whether the SSH service is run, add the following line like:
config.vm.provision :shell, run: "always", path: "scripts/check_ssh_service.sh"
Similar issue: Apache doesn't start after Vagrant reload
Finally check the following list for possible solutions to the SSH timeout problem:
Make sure your firewall or antivirus is not blocking the program (which I doubt will happen often)
Give your vagrant machine some time for timeouts to happen. If you dont have a very fast PC / Mac, the VM will take while to boot into an
SSH ready state, so timeouts will happen.
Therefore, first try to let vagrant timeout COMPLETELY before concluding that there is a fault.
If vagrant times out completely then increase the timeout limit in the vagrant file to a few min and try again.
If that still doesnt work, then try to clean boot your vagrant machine through the VirtualBox interface and enable the GUI of the
machine beforehand. If the GUI doesn't show anything happening (ie.
just blackscreen, no text) while it is booting, then your vagrant
machine has got problems.
Destroy the entire machine through the VB interface and reinstall.
Delete the ubuntu image files in the Vagrant Images folder in the user folder and redownload and install.
Do you even have an intel processor that supports 64bit hardware virtualisation? Google it. If you do, make sure there is no setting in
your Bios disabling this feature.
Disable hyper-v feature if you are running windows 7 or 8. Google how to disable.
Make sure you are running through an SSH enabled client. Use Git bash. Download: http://git-scm.com/downloads
Install a 32bit version of ubuntu like trusty32 or precise32. Just change the version in the vagrant file and reinstall vagrant in new
directory.
Make sure you are using the latest vagrant and virtualbox versions.
Last resorts: Format your computer, reinstall windows and buy an intel core isomething processor.
Source: GitHub post by #dezinerdudes
See also: SSH Timeout - Cant connect via ssh no matter what

vagrant stuck at "default: Warning: Connection timeout. Retrying..."

I googling for some days and i do not find any solution to solve my problem.
I pretty sure, This problem not from VT-x because I using bento/ubuntu-14.04-i386 on Windows 8.1 (I guess my CPU allow to use 32bit as guest but 64bit dont C2D E7200)
I clone github repo from laravel/settler and replace config.vm.box = 'bento/ubuntu-14.04' into config.vm.box = 'bento/ubuntu-14.04-i386' on Vagrantfile
And start vagrant with vagrant up and i get this
λ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'bento/ubuntu-14.04-i386'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'bento/ubuntu-14.04-i386' is up to date...
==> default: Setting the name of the VM: settler_default_1446635664316_42330
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 80 => 8000 (adapter 1)
default: 3306 => 33060 (adapter 1)
default: 5432 => 54320 (adapter 1)
default: 35729 => 35729 (adapter 1)
default: 22 => 2222 (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 timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.
If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.
If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
vagrant ssh-config
Host default
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile C:/Users/Jame/.vagrant.d/insecure_private_key
IdentitiesOnly yes
LogLevel FATAL
vagrant global-status
id name provider state directory
------------------------------------------------------------------------------------------
87ba96c default virtualbox running C:/Users/Jame/Dropbox/Private/myscript/config/settler
The above shows information about all known Vagrant environments
on this machine. This data is cached and may not be completely
up-to-date. To interact with any of the machines, you can go to
that directory and run Vagrant, or you can use the ID directly
with Vagrant commands from any directory. For example:
"vagrant destroy 1a2b3c4d"
and GUI is
Please help, Thank :)
This might have various reasons and it's mostly about private / public keys. You can follow these step to troubleshoot:
1) First of all try if you can ssh with password to make sure that it's about keys. If you can't, then you should first find the reason for that and step 3 would be helpful in that case too.
2) Second thing to do is to find out which private key vagrant is using.
Run vagrant ssh-config and check IdentityFile, in your case this is the default insecure_private_key provided by vagrant.
3) Now run vagrant ssh -- -v which will show you the details of ssh progress, double check the private key that is used. If you see smt. like this at the end you can be sure that server cannot match your public key and that's the problem:
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /Users/ozan/.vagrant.d/insecure_private_key
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: password
vagrant#127.0.0.1's password:
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
vagrant#127.0.0.1's password:
4) ssh your guest with password and check if the public key is ok. You should check the permissions of the ~/.ssh directory and the /.ssh/authorized_keys file. They must be 755 (drwx------) and 600 (-rw-------) respectively and they must be owned by vagrant user.
5) Check that the public key matches your private key. To do so generate the public key from private key like ssh-keygen -f ~/.vagrant.d/insecure_private_key -y on your host and compare it with the one in ~/.ssh/authorized_keys
Also make sure that the keys is in the ~/.ssh/authorized_keys are on a single line, if you do smt. like copy paste it can happen that newline characters are inserted which will obviously break the public key.
And here are some notes about vagrant and homestead which would help:
Normally vagrant replaces this insecure_private_key with some secure one and adjusts everything at startup or halt if config.ssh.insert_key is set totrue in you configuration (which is the default in the latest version 1.7.4). So you might see some path under your .vagrant directory for the IdentityFile.
The problem in my case was, you can define which private key to use in your Homestead.yaml normally, however homestead didn't respect the custom keys for some reason, and vagrant didn't replace the insecure key too...
So I basically generated and copied the public key of the private key that is listed as IdentityFile and put it into authorized_keys which did solve the issue.
After fixing the public key I realized that vagrant replaced the insecure_private_key with some secure one successfuly...

Solution for vagrant installation

i need your help because i have to use cakebox for a project but i have some problems when i type vagrant up i get this error. I tried everything but it did not work.
Thanks in advance !
My-PC MINGW64 /A/App_LeagueUp!/cakebox (dev)
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'cakebox'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: cakebox_default_1444639086577_31058
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 => 2222 (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 timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
default: Warning: Connection timeout. Retrying...
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.
If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.
If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
My recomendation to figure out the problem is to set the
vb.gui flag to true in your Vagrantfile . add run then vagrant up. this will open the console, on a different window. It sometimes happen to me and then i reboot and everything is working fine.
If it doesnt post findings here, at least youll have more info
Try to enable virtualization from your boot menu and try it again.

Why does Vagrant not work right out of the box on Windows 7?

Windows 7 64-bit here. Went to the Vagrant stable version downloads page. Downloaded the Windows 64-bit installer, installed using all recommended defaults, and rebooted.
Then read their Getting Started Guide. Opened a command prompt:
vagrant init hashicorp/precise32
And see the following output:
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
OK. So far so good. Then I do:
vagrant up
And here is the output:
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'hashicorp/precise32' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
==> default: Loading metadata for box 'hashicorp/precise32'
default: URL: https://atlas.hashicorp.com/hashicorp/precise32
==> default: Adding box 'hashicorp/precise32' (v1.0.0) for provider: virtualbox
default: Downloading: https://atlas.hashicorp.com/hashicorp/boxes/precise32/versions/1.0.0/providers/virtualbox.box
default:
==> default: Successfully added box 'hashicorp/precise32' (v1.0.0) for 'virtualbox'!
==> default: Importing base box 'hashicorp/precise32'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'hashicorp/precise32' is up to date...
==> default: Setting the name of the VM: vms_default_1421176231425_15801
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 22 => 2222 (adapter 1)
==> 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: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Authentication failure. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
default: Warning: Remote connection disconnect. Retrying...
Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.
If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.
If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.
If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
Then I read the next part of the Getting Started Guide:
Now imagine every project you've ever worked on being this easy to set up.
LOL
Why am I getting this error?

Vagrant mount multiple folders on the same point - logout

I try to NFS mount 3 folders into my own vagrant box (I created this box with CentOS),
but it seems always mount the folders on the same point (/home/vagrant/logout)
here is my Vagrantfile:
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "my_box"
config.vm.network "private_network", ip: "192.168.100.100"
config.ssh.pty = true
config.vm.synced_folder ".", "/vagrant", type: "nfs"
config.vm.synced_folder "../Larvata/a", "/home/A", type: "nfs"
config.vm.synced_folder "../Larvata/b", "/home/B", type: "nfs"
config.vm.synced_folder "../Larvata/c", "/home/C", type: "nfs"
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--memory", "512"]
end
end
my vagrant up message:
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
default: Adapter 2: hostonly
==> default: Forwarding ports...
default: 22 => 2222 (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: Error: Connection timeout. Retrying...
default: Error: Remote connection disconnect. Retrying...
default: Error: Remote connection disconnect. Retrying...
default: Error: Remote connection disconnect. Retrying...
default: Error: Remote connection disconnect. Retrying...
default: Error: Remote connection disconnect. Retrying...
default: Error: Remote connection disconnect. Retrying...
default: Error: Remote connection disconnect. Retrying...
default: Error: Remote connection disconnect. Retrying...
default: Error: Remote connection disconnect. Retrying...
default: Error: Remote connection disconnect. Retrying...
default: Error: Remote connection disconnect. Retrying...
default: Error: Remote connection disconnect. Retrying...
default: Error: Remote connection disconnect. Retrying...
default: Error: Remote connection disconnect. Retrying...
default: Error: Remote connection disconnect. Retrying...
default: Error: Remote connection disconnect. Retrying...
default: Error: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...
==> default: Exporting NFS shared folders...
==> default: Preparing to edit /etc/exports. Administrator privileges will be required...
Password:
==> default: Mounting NFS shared folders...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
mount -o 'vers=3,udp' 192.168.100.1:'/Users/zx1986/Larvata/A' logout
Stdout from the command:
export TERM=vt100
mount -o 'vers=3,udp' 192.168.100.1:'/Users/zx1986/Larvata/B' logout
exit
export TERM=vt100
logoutmount -o 'vers=3,udp' 192.168.100.1:'/Users/zx1986/Larvata/C
mount.nfs: /home/vagrant/logout is busy or already mounted
exit
logout
Stderr from the command:
this /etc/exports generated by vagrant:
# VAGRANT-BEGIN: 501
"/Users/zx1986/Box" 192.168.100.100 -alldirs -mapall=501:20
"/Users/zx1986/Larvata/a" 192.168.100.100 -alldirs -mapall=501:20
"/Users/zx1986/Larvata/b" "/Users/zx1986/Larvata/c" 192.168.100.100 -alldirs -mapall=501:20
# VAGRANT-END: 501
Virtaulbox 4.3.12
Vagrant 1.5.1
MacOS 10.9.3
Any idea or clues?
I have googled for a while, but haven't seem anything about the "logout" mount point.

Resources