无法从VPN上的主机(CISCO AnyConnect)连接到Vagrant专用网络

时间:2016-03-19 22:46:00

标签: networking vagrant virtual-machine virtualbox vagrantfile

在VPN连接上(到我办公室的另一个位置),我的流浪者盒子无法通过浏览器访问。它在我的办公室位置工作正常。

这里是流浪汉重装:

==> 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.

我多次尝试连接。

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

我想访问我机器上的网络服务器。

我也尝试过NAT端口转发:

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

它对我不起作用。

2 个答案:

答案 0 :(得分:0)

我对网络设置和你想要实现的目标感到有点困惑。如果流浪者访客在您的本地计算机上,您只需在浏览器中键入http://localhost:8080即可访问它,而VPN实际上并不重要。

如果流浪者访客位于另一个您要通过VPN运行的网络上的另一台计算机上,那么只要本地计算机上的VPN连接已启动,您就可以通过附加:8080来访问它。盒子的IP。根据您发布的代码,可以是http://10.0.2.15:8080http://192.168.33.10:8080

如果我误解了这个问题,请附上其他信息评论!

答案 1 :(得分:0)

这是一种解决方法 - 而非修复方法。打开笔记本电脑/工作站电源后,但在启动Cisco AnyConnect之前,启动你的虚拟机(即流浪者)。确保您可以通过浏览器连接到虚拟机中的应用程序。然后启动AnyConnect。

只要你在AnyConnect之前启动你的vm,你应该能够根据需要经常“流浪”和“流浪[无论如何”],而无需重新启动。每次打开笔记本电脑/工作站电源时都需要重复此过程。至少这对我们有用。祝你好运!