Search code examples
vagrant

Vagrant keeps creating unwanted network interfaces


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)

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.

How can I prevent this and have my desired 192.168.x.y/24 set on eth0?

Best, Edoardo


Solution

  • 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).

    That's why you have 2 NICs even though you have only 1 config.vm.network in Vagrantfile.

    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.