VMWare 融合 NAT +主机隧道;从虚拟机访问

发布于 2024-09-27 16:29:32 字数 357 浏览 0 评论 0原文

我无法从虚拟机访问 OSX 主机上的端口。

我在 VMware fusion 中使用 NAT。在我的(OSX 主机)主机文件中,我将 vmnet8 的 IP 地址映射到“mac”。

从我的虚拟机中,我可以“ssh user@mac”并且它按预期工作:我已登录到主机。所以,我的主机文件正在工作。

我有一条从 OSX 主机到工作中的 Oracle 服务器的隧道。我可以从主机使用隧道(localhost:6004)没有问题。但是,如果我尝试使用名称“mac”而不是“localhost”,则这不起作用。因此,我也无法从虚拟机访问隧道。 (显然,我不能使用虚拟机中的本地主机名称)。

为什么无法使用“mac”访问隧道,而 ssh 工作正常?

I'm having trouble accessing a port on my OSX host from a vm.

I'm using NAT in VMware fusion. In my (OSX host) hosts file, I have the ip address for vmnet8 mapped to 'mac'.

From my vm, I can 'ssh user@mac' and it works as expected: I am logged into the host. So, my hosts file is working.

I have a tunnel from my OSX host to an Oracle server at work. I can use the tunnel (localhost:6004) from the host no problem. However if I try to use the name 'mac' instead of 'localhost' this does not work. As a result, I am not able to access the tunnel from the vm, either. (I can't use the localhost name from the vm, obviously).

Why isn't the tunnel accessible using 'mac', while ssh works fine?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

看透却不说透 2024-10-04 16:29:32

好吧,我想事情已经按照我想要的方式进行了。

10.0.0.1 映射到 /etc/hosts 中的“mac”

sudo ifconfig lo0 add 10.0.0.1

sudo ipfw add fwd 127.0.0.1 tcp from any to 10.0.0.1

显然,我不是网络专家,所以我无法确切地说出为什么它有效,而我的第一次尝试却没有。

不管怎样,它允许我在虚拟机中将主机操作系统称为“mac”,此外还允许我从虚拟机内访问主机上的任何 ssh 隧道(例如 mac:9004)。此外,通过将我的虚拟机 IP 地址映射到 /etc/hosts(在主机上),所有虚拟机和主机似乎都能够通过名称进行完美通信。

Okay, I got things working the way I want - I think.

10.0.0.1 is mapped to 'mac' in /etc/hosts

sudo ifconfig lo0 add 10.0.0.1

sudo ipfw add fwd 127.0.0.1 tcp from any to 10.0.0.1

Not a networking expert, obviously, so I couldn't say exactly why this works and my first attempt didn't.

Anyway, it allows me to refer to the host os as 'mac' from my VMs, and in addition allows me to access any ssh tunnels on the host from within the VMs (e.g. mac:9004). In addition, by mapping my VM ip addresses in /etc/hosts (on the host), all VMs and the host seem to be able to communicate flawlessly by name.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文