简体   繁体   English

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

[英]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. 在VPN连接(到我办公室的另一个位置)上,无法通过浏览器访问我的游民箱。 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: 在无业游民上的IP地址显示:

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. 我想访问我机器上的Web服务器。

I also tried NAT port forwarding : 我还尝试了NAT端口转发:

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

It doesn't work for me . 它对我不起作用。

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. 如果无业游民的访客在您的本地计算机上,则可以通过在浏览器中键入http://localhost:8080来访问它,而VPN并不重要。

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. 如果无业游民的来宾在另一个网络上,而您要通过VPN穿越另一个网络,那么只要本地计算机上的VPN连接已建立,您就可以通过在框的IP上附加:8080来访问它。 From the code you posted, that could be either http://10.0.2.15:8080 or http://192.168.33.10:8080 . 从您发布的代码中,可以是http://10.0.2.15:8080http://192.168.33.10:8080

If I have misunderstood the question, please comment with additional information! 如果我误解了这个问题,请发表评论并提供更多信息!

This is a workaround--not a fix. 这是一种解决方法-不是修复程序。 After you power on your laptop/workstation, but before starting Cisco AnyConnect, start your vm (ie, vagrant up). 在打开笔记本电脑/工作站的电源之后,但是在启动Cisco AnyConnect之前,请启动您的虚拟机(即,无所事事)。 Make sure you can connect to an app in the vm via the browser. 确保可以通过浏览器连接到虚拟机中的应用程序。 Then start AnyConnect. 然后启动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. 只要在AnyConnect之前启动虚拟机,您就应该能够根据需要“频繁”启动和“虚拟化”所有虚拟机,而无需重新启动。 You'll need to repeat that process every time you power on your laptop/workstation. 每次打开笔记本电脑/工作站时,都需要重复该过程。 At least that works for us. 至少对我们有用。 Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM