SAC
SAC

Reputation: 243

Not able to connect to Vagrant private network from host on VPN (CISCO AnyConnect)

On VPN connection ( to another location of my office ), my vagrant box is not reachable via browser. Its working fine in my office location.

here is vagrant reload:

==> default: Attempting graceful shutdown of VM...
==> 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 (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: 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: 4.3.10
    default: VirtualBox Version: 5.0
==> default: Configuring and enabling network interfaces...
==> default: Mounting shared folders...
    default: /vagrant => /Users/sachinkushwaha/Workspace/vagrant-quikr
    default: /home/axle => /Users/sachinkushwaha/Workspace/quikraxledashboard
    default: /home/data => /Users/sachinkushwaha/Workspace/quikr_prod/QuikrBaseCode
    default: /home/vhosts => /Users/sachinkushwaha/Workspace/vhosts
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.

I tried to connected many times .

Ip addr show on vagrant:

vagrant@vagrant-ubuntu-trusty-64:~$ ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:27:3e:96:5b brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::a00:27ff:fe3e:965b/64 scope link 
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:27:d7:25:82 brd ff:ff:ff:ff:ff:ff
    inet 192.168.33.10/16 brd 192.168.255.255 scope global eth1

I wanted to access the web server on my machine.

I also tried NAT port forwarding :

Vagrant.configure("2") do |config|
  config.vm.network "forwarded_port", guest: 80, host: 8080,
    auto_correct: true
end

It doesn't work for me .

Upvotes: 1

Views: 1787

Answers (2)

Nes Fel
Nes Fel

Reputation: 21

This is a workaround--not a fix. After you power on your laptop/workstation, but before starting Cisco AnyConnect, start your vm (i.e., vagrant up). Make sure you can connect to an app in the vm via the browser. Then start AnyConnect.

As long as you start your vm before AnyConnect, you should be able to "vagrant up" and "vagrant [whatever]" the vm as often as needed without rebooting. You'll need to repeat that process every time you power on your laptop/workstation. At least that works for us. Good luck!

Upvotes: 2

Brian Brownton
Brian Brownton

Reputation: 1331

I'm a bit confused about the network setup and what you are trying to achieve. If the vagrant Guest is on your local machine, you can access it by simply typing http://localhost:8080 in your browser and the VPN shouldn't really matter.

If the vagrant Guest is on another machine on another network, which you are VPN to traverse, then as long as the VPN connection on your local machine is up you should be able to access it by appending :8080 to the IP of the box. From the code you posted, that could be either http://10.0.2.15:8080 or http://192.168.33.10:8080.

If I have misunderstood the question, please comment with additional information!

Upvotes: 0

Related Questions