无法在使用 Cisco VPN AnyConnect 时将 docker-machine 与 virtualbox 配合使用

19

当我使用Cisco VPN Anyconnect连接到公司网络时,我无法让docker-machine连接到我的virtualbox VM。这似乎与Cisco Anyconnect接管所有192.168.路由有关。我还尝试使用完全不同的cidr范围(25.0.1.100/24),但仍然无法使docker-machine与VM通信。当我检查路由表时,路由被添加到utun0而不是vboxnet0。我认为utun0是VPN的主机网络接口。以下是docker-machine的输出:

docker-machine create -d virtualbox dev   
Running pre-create checks...
Creating machine...
Waiting for machine to be running, this may take a few minutes...
Machine is running, waiting for SSH to be available...
Detecting operating system of created instance...
Provisioning created instance...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
WARNING >>> 
This machine has been allocated an IP address, but Docker Machine could not
reach it successfully.

SSH for the machine should still work, but connecting to exposed ports, such as
the Docker daemon port (usually <ip>:2376), may not work properly.

You may need to add the route manually, or use another related workaround.

This could be due to a VPN, proxy, or host file configuration issue.

You also might want to clear any VirtualBox host only interfaces you are not using.
To see how to connect Docker to this machine, run: docker-machine env dev

当我断开VPN连接时,它可以正常工作并将路由添加到vboxnet0(没有utun0网络接口)。 - Dhawal
3个回答

17

我有一个类似的IP冲突问题,是在192.168.x.x上解决的,我通过改变VirtualBox host-only网络的子网来解决它。

1) 运行docker-machine rm dev

2) 进入VirtualBox首选项并删除host-only网络

3) 运行docker-machine create --driver virtualbox --virtualbox-hostonly-cidr "25.0.1.100/24" dev

这里还有一个Github讨论:https://github.com/docker/kitematic/issues/1029#issuecomment-156219462


1
这个可行!我还需要运行 docker-machine env 来设置正确的环境变量。 - Caleb_Allen
我正在使用VirtualBox 6.1.22,但在多次重启、删除主机适配器等操作后,在docker-machine的最新安装版本0.16.0, build 702c267f上仍然遇到与原帖作者相同的错误。我已经开始了一个悬赏,希望能够得到任何必要的更新。谢谢! - Brad Parks
@BradParks 你的操作系统、路由表(有和没有 VPN 的)以及 Docker 机器的 IP 是什么(docker-machine env)?问题通常出现在 VPN 管理员不允许 VPN 分流的情况下。但是,如果你是使用机器的管理员,那么你可以创建自己的“分流” - 它需要针对特定用例进行低级网络配置(操作系统、路由、网络 CIDR 等)。 - Jan Garaj
感谢您的反馈 - 我使用的是Mac Big Sur,无法对AnyConnect进行配置/设置,因为我正在使用VPN工作,不能更改为分割隧道或任何可能破坏VPN配置的内容。如果您有关于在这些限制条件下可行的答案建议,请发布并让我尝试! - Brad Parks

4

1
如果您可以选择在 Split Tunnel(而不是Full Tunnel)模式下运行Cisco VPN,这似乎很有效,同时仍允许您访问公司网络。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接