Vagrant 不断创建不需要的网络接口 [英] Vagrant keeps creating unwanted network interfaces
问题描述
我正在创建一个虚拟机定义,我想在盒子的主界面上指定一个private_network"(eth0,它是 Linux)
I'm creating a VM definition and I want to specify a single "private_network" on the primary interface of the box (eth0, it's Linux)
尽管只有一个 config.vm.network 语句,但我一直在 eth1 上设置所需的网络,而 eth0 分配了一个来自我从未定义的 10.0.2.0/24 子网的 IP.
Despite having only one config.vm.network statement, I keep getting the desired network set on eth1, while eth0 is assigned an ip from a 10.0.2.0/24 subnet which I have never defined.
如何防止这种情况发生并在 eth0 上设置我想要的 192.168.x.y/24?
How can I prevent this and have my desired 192.168.x.y/24 set on eth0?
最好的,爱德华多
推荐答案
eth0
默认被 Vagrant 用于 NAT(VirtualBox NAT 网络模式),它允许你 vagrant ssh
到框中(端口转发规则 - 主机 2222 <=> 来宾 22).
eth0
is by default used by Vagrant for NAT (VirtualBox NAT networking mode), which allow you to vagrant ssh
into the box (port forwarding rules - host 2222 <=> guest 22).
这就是为什么即使 Vagrantfile
中只有 1 个 config.vm.network
你有 2 个 NIC.
That's why you have 2 NICs even though you have only 1 config.vm.network
in Vagrantfile
.
我不认为它可以被禁用,但我不是 100% 确定,您可能需要查看 vagrant 源代码以进一步挖掘.
I don't think it can be disabled, BUT I am not 100% sure, you may want to look into vagrant source code to dig further.
这篇关于Vagrant 不断创建不需要的网络接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!