virtualbox 文档没有解释清楚。
https://www.virtualbox.org/manual/ch09.html
9.11.5. Enabling DNS proxy in NAT mode The NAT engine by default offers the same DNS servers to the guest that are configured on the host. In some scenarios, it can be desirable to hide the DNS server IPs from the guest, for example when this information can change on the host due to expiring DHCP leases. In this case, you can tell the NAT engine to act as DNS proxy using the following command:
VBoxManage modifyvm "VM name" --natdnsproxy1 on
9.11.6. Using the host's resolver as a DNS proxy in NAT mode For resolving network names, the DHCP server of the NAT engine offers a list of registered DNS servers of the host. If for some reason you need to hide this DNS server list and use the host's resolver settings, thereby forcing the VirtualBox NAT engine to intercept DNS requests and forward them to host's resolver, use the following command:
VBoxManage modifyvm "VM name" --natdnshostresolver1 on Note that this setting is similar to the DNS proxy mode, however whereas the proxy mode just forwards DNS requests to the appropriate servers, the resolver mode will interpret the DNS requests and use the host's DNS API to query the information and return it to the guest.
谁能真正理解其中的区别?
编辑:需要一个实际的例子。
最佳答案
如果 natdnsproxy
如果启用了 NAT 类型的网络适配器选项,VirtualBox 的 NAT 网关将接受来自 guest 的 DNS 流量并将其转发到主机使用的解析器。它将仅充当网络层代理。只有发送到网关 IP 的 DNS 流量会被重定向,它不会拦截发送到其他 IP 的 DNS 流量。确保您的访客使用您的网关 IP(例如 10.0.2.2
)作为解析器(如果您的访客使用 DHCP,这应该可以直接使用)。natdnshostresolver
选项类似——它也会导致 NAT 网关接受 DNS 流量——但网关将读取(即解析)查询并使用主机的操作系统 API 来解决它。在 Linux 上,这将是 getaddrinfo()
.这是恕我直言的首选选项。
数字 (1
) 指的是网络适配器,可以互换。 --natdnshostresolver2 on
将为给定 VM 的第二个接口(interface)启用该选项。
关于dns - virtualbox:--natdnsproxy1 和--natdnshostresolver1 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51060639/