VirtualBox + Vagrant + Homestead + VPN = SSH issue

1,222 views
Skip to first unread message

Jrean

unread,
Feb 3, 2015, 12:46:37 AM2/3/15
to vagra...@googlegroups.com
Hi,

The blocking problem is the following:


When I homestead up or vagrant up and I try to connect trough SSH it takes a while to connect then each keystroke is interpreted with a minimum delay of 2 minutes each making it absolutely unusable...


The configuration is the following:

    Os X 10.10.2
    VirtualBox 4.3.20
    Vagrant 1.7.2
    laravel/homestead (virtualbox, 0.2.2)

I did some tests and I found a path to explore:

I use a VPN which is configured with Viscosity (1.0 / last update) (all traffic is sent over VPN connection). I'm also using Little Snitch 3.5.1. Both are perfectly working and seems to be pretty much well configured. I'm connected over Wifi. I use Little Snitch profiles to create a kind of global Kill Switch when the VPN is not connected. So if Wifi is enabled and connected AND VPN is not connected, Little Snitch is blocking any outgoing/incoming connection (excepting some special rules) to avoid the grey zone and any leaks...


I discovered:

    If Wifi is enabled and VPN is connected the SSH issue(s) appears.
    If Wifi is enabled and VPN is NOT connected the SSH issue(s) disappears. (no issues, normal behaviour)

The path:

I'm pretty sure I need to set (properly) VirtualBox Network Settings. I'm not at all an expert and I would appreciate some kind help.


Here are some logs:

(Default) Homestead / Settings / Network

    Adaptater 1 is NAT
    Adaptater 2 is Host-Only Adaptater
    (Kill Switch active) Wifi enabled + VPN disabled

I am aware that no internet connection is available since Little Snitch deny anything.


homestead up / vagrant up outputs the following:

CODE:
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'laravel/homestead' is up to date...
==> default: There was a problem while downloading the metadata for your box
==> default: to check for updates. This is not an error, since it is usually due
==> default: to temporary network problems. This is just a warning. The problem
==> default: encountered was:
==> default:
==> default: Failed to connect to xx.xxx.xx.xxx: Host is down
==> default:
==> default: If you want to check for box updates, verify your network connection
==> default: is valid and try again.
==> 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: 80 => 8000 (adapter 1)
    default: 443 => 44300 (adapter 1)
    default: 3306 => 33060 (adapter 1)
    default: 5432 => 54320 (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: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => /Users/xxx/.composer/vendor/laravel/homestead
    default: /home/vagrant/code => /Volumes/xxx/code
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: to force provisioning. Provisioners marked to run always will still run.


Then if I perform homestead ssh it outputs:

CODE:
Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-30-generic x86_64)

 * Documentation:  xx

  System information as of Mon Feb  2 07:36:04 UTC 2015

  System load:  0.66              Processes:           103
  Usage of /:   5.0% of 39.34GB   Users logged in:     0
  Memory usage: 29%               IP address for eth0: xx.x.x.xx
  Swap usage:   0%                IP address for eth1: xxx.xxx.xx.xx

  Graph this data and manage this system at:
    xx

  Get cloud support with Ubuntu Advantage Cloud Guest:
    xx


Last login: Mon Feb  2 06:46:17 2015 from xx.x.x.x
vagrant@homestead:~$


So we can consider it's working correctly (booting in few seconds).

Wifi enabled + VPN enabled

Internet connection is available.

homestead up outputs the following:

CODE:
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'laravel/homestead' is up to date...
==> 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: 80 => 8000 (adapter 1)
    default: 443 => 44300 (adapter 1)
    default: 3306 => 33060 (adapter 1)
    default: 5432 => 54320 (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: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Setting hostname...
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => /Users/xxx/.composer/vendor/laravel/homestead
    default: /home/vagrant/code => /Volumes/xxx/code
Guest-specific operations were attempted on a machine that is not
ready for guest communication. This should not happen and a bug
should be reported.


I want to highlight the following code:

CODE:
Guest-specific operations were attempted on a machine that is not
ready for guest communication. This should not happen and a bug
should be reported.


Then performing homestead ssh takes ages (at least 3 to 4 minutes) to connect with the following output:

CODE:
Welcome to Ubuntu 14.04.1 LTS (GNU/Linux 3.13.0-30-generic x86_64)

 * Documentation:  xx

  System information as of Mon Feb  2 07:50:06 UTC 2015

  System load:  0.74              Processes:           103
  Usage of /:   5.0% of 39.34GB   Users logged in:     0
  Memory usage: 29%               IP address for eth0: xx.x.x.xx
  Swap usage:   0%                IP address for eth1: xxx.xxx.xx.xx

  Graph this data and manage this system at:
    xx

  Get cloud support with Ubuntu Advantage Cloud Guest:
    xx


Last login: Mon Feb  2 07:41:53 2015 from xx.x.x.x
vagrant@homestead:~$


At this point, it is absolutely unusable because pressing any keystroke will take minutes to resolve.

I'm pretty sure the problem comes from a bad configuration from Virtualbox / Settings / Network / Adaptater or something I should put in a VagrantFile.

The connection path seems to be: host machine -> VPN server -> host machine -> VM

I would like it to be: host machine -> VM because when working on my code and with the VM, I still want to use internet on my host machine as normally (trough my VPN).

When VPN is enabled, VM external IP = VPN IP:


When VPN is disabled, VM external IP = ISP IP:


Thank you in advance for your help.

Regards,

Jean

Alvaro Miranda Aguilera

unread,
Feb 3, 2015, 3:30:30 AM2/3/15
to vagra...@googlegroups.com
Hello,

Seems is the routing on the vpn as you said...


From what you said about your config.

Adaptater 1 is NAT

Adaptater 2 is Host-Only Adaptater


if you do, vagrant config-ssh and you get the information to connect
directly without vagrant ssh, can you do the following test please:

a. connect to the nat port.. 127.0.0.1 port 2222 by default..
b. connect to the host only ip

do you feel both slow/the same?

test c if you have time

can you create a 3rd card, bridge and do the same test?

That should help you to find an usable path.. then, you may use that
non-slow path to connect once the vm is booted.
> --
> You received this message because you are subscribed to the Google Groups
> "Vagrant" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to vagrant-up+...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

JeanJean

unread,
Feb 3, 2015, 8:09:25 AM2/3/15
to vagra...@googlegroups.com
Hi,

Thank you for your time and your answer.

Vagrant command vagrant ssh-config outputs the following:

Host default:
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile /Users/xxx/.composer/vendor/laravel/homestead/.vagrant/machines/default/virtualbox/private_key
IdentitiesOnly yes
LogLevel FATAL


Can you consider writing me the command you want me to perform as “baby steps”?

a. Connect to the nat port 127.0.0.1 port 2222 by default..
=> Do you mean ssh vag...@127.0.0.1 -p 2222 ?
=> Very slow! Same problem encountered.

b. Connect to the host only ip
=> Who is the host, who is the guest. Sorry I’m lost. What “only IP” do you mean?

When I’m connected over SSH with ssh vag...@127.0.0.1 -p 2222 or the vagrant ssh command I can read the following with ifconfig:
eth0: 10.0.2.15
eth1: 192.168.10.10
lo: 127.0.0.1

ssh vag...@10.0.2.15 -p 2222 outputs Operation time out
ssh vag...@192.168.10.10 -p 2222 outputs Connection refused

Also when I curl -L http://dazzlepod.com/ip/me.json my VM is right under my VPN IP adresse (when VPN is enabled)

c. Can you create a 3rd car, bridge and do the same test?
=> Do you mean create a 3rd Adapter and select “Bridged Adapter” in VirtualBox / Settings / Network?
=> What should I do after creating that 3rd Adapter?

The funny part is if I’m connected over SSH (for instance trough ssh vag...@127.0.0.1 -p 2222) as soon as I turn off my VPN connection it automatically starts working perfectly again and fast!! As soon as I turn on again my VPN connection it works great for a short delay and starts lagging for ages..!

It drives me crazy.

I hope we will find.

Regards,

J.


You received this message because you are subscribed to a topic in the Google Groups "Vagrant" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vagrant-up/5NIHn8t3sJQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vagrant-up+...@googlegroups.com.

Alvaro Miranda Aguilera

unread,
Feb 3, 2015, 3:33:23 PM2/3/15
to vagra...@googlegroups.com
Hello!

Ok, Host is the machine where you run vagrant.
Guest is the virtualvm that is created with vagrant.

The VPN is probably causing routing issues, so that's why I am asking
you to test different connections, so you can test the speed.

Ideally, once you find one path that goes faster, you will be able to
do some workaround.

First. Do you need the vpn on the host?? some VPN cause this
behaviour, so some people (me included) vpn from a vm.. I use a
windows vm ..

back to the troubleshooting.


a. Connect to the nat port 127.0.0.1 port 2222 by default..
=> Do you mean ssh vag...@127.0.0.1 -p 2222 ?
=> Very slow! Same problem encountered.

This is done.


b. Connect to the host only ip

The 2nd nic on the guest vm, is on a network you called host-only,
that is a network that only exist between the host and the vm. so
being local it shouln't be routed at all.

You found the ip:
192.168.10.10

so please try ssh vag...@192.168.10.10 -p 22


then also test http://192.168.10.10/

It should go faster here...

If doesn't, the 3rd test is

c. can you create a 3rd car, bridge and do the same test?

To do this, add this to the Vagrantfile, after the other network

config.vm.network "public_network"

Then do a vagrant reload

it should ask to what interface in the host bridge, choose the one you
are connected, can be wifi or lan.. should be easy to answer.

Then, check on the guest what Ip have, it should have eth2 <ip>

then repite:

ssh vagrant@ip -p 22
http://ip/


if one of this connections works better, we may do something.

thanks!

JeanJean

unread,
Feb 5, 2015, 11:13:39 PM2/5/15
to vagra...@googlegroups.com
Hi Alvaro,

Here I come with some results :)
Thank you again for your time.

Do you need the vpn on the host?? some VPN cause this
behaviour, so some people (me included) vpn from a vm.. I use a
windows vm ..

The host is my computer (Macbook Air), my only machine.
I need it everyday so Yes I need the VPN on the host.
I could have say I don’t need VPN on the guest machine…

homestead ssh
=> working but slower to bring the prompt than others

=> ssh: connect to host 127.0.0.1 port 22: Connection refused

ssh vag...@127.0.0.1 -p 2222
=> working

=> ssh: connect to host 192.168.10.10 port 2222: Connection refused

=> working

=> working

=> working

=> not working

=> working

=> not working


With Viscosity (software I use along with my VPN) I had configured custom statics DNS from OpenVpn.
On my Mac I had also configured within System Preferences / Network / Wi-fi / Advanced… / DNS custom statics DNS.
I remove that settings from both my Mac and Viscosity. Now DNS are automatically managed in Viscosity which receive VPN's DNS.

This change changed the behaviour of my lagging issue. I don’t clearly understand why. Do you?

It’s very frustrating not to be able to 100% manage and make things work.

Here is also a sample of the “Vagrantfile” provided for Homestead:

# Configure A Private Network IP config.vm.network :private_network, ip: settings["ip"] ||= "192.168.10.10" # Configure A Few VirtualBox Settings config.vm.provider "virtualbox" do |vb| vb.name = 'homestead' vb.customize ["modifyvm", :id, "--memory", settings["memory"] ||= "2048"] vb.customize ["modifyvm", :id, "--cpus", settings["cpus"] ||= "1"] vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"] vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] vb.customize ["modifyvm", :id, "--ostype", "Ubuntu_64"] end


Regards.

Alvaro Miranda Aguilera

unread,
Feb 6, 2015, 4:02:14 AM2/6/15
to vagra...@googlegroups.com
my suggestion was...

can you have a vm, use the vpn in the vm, and then, inside that vm, use whatever you need over the vpn

Say you create a windows 7 machine, setup and connect to the vpn, and then use that vm to do work over the vpn.

====

back to your question.. are 2 things that can cause troubes using vpn on the host

network routes
dns settings


For the first one, sometimes some company decide to route ALL the traffic over the vpn..

For the DNS, sometimes, they force the host to change the dns settings, use the dns of the vpn,  and even worst, they only resolve .mycompany.com and they use proxy for the rest..

so is quite difficult say one rule that fits all.

Usually using a bridge network on the vm machine fix the first problem.. and having manually set the resolver, /etc/resolv.conf to use your home dns (ip of router) or just 8.8.8.8 and 8.8.4.4 will do the trick

other than that, I am afraid that the best person to ask is someone that manage the vpn, and ask them for advise.

that's why sometimes is less trouble use a vm, and vpn from there.

Sorry for not being more helpful, 
Alvaro.

Reply all
Reply to author
Forward
0 new messages