How to switch order of network adapters in Vagrant

2019-05-23 09:54发布

Under Vagrant I have config something like this:

Vagrant.configure(2) do |config|
  config.vm.box = "ubuntu/trusty64"
  config.vm.provider "virtualbox" do |vb|
     vb.memory = "512"
  end
  config.vm.host_name = 'core.example.com'
  config.vm.network "forwarded_port", guest: 22, host: 2222, id: 'ssh'
  config.vm.network "private_network", ip: '172.28.128.3'
  config.vm.synced_folder "./vagrant_core", "/vagrant", create: true
end

And after this I receiving something like that:

Adapter eth0 -> NAT
Adapter eth1 -> 'Private_network'

ifconfig:

eth0      Link encap:Ethernet  HWaddr 08:00:27:cf:da:f3  
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0

eth1      Link encap:Ethernet  HWaddr 08:00:27:8f:cb:52  
          inet addr:172.28.128.13  Bcast:172.28.128.255  Mask:255.255.255.0

Is there any way to switch them ? I need private_network under eth0.

Regarding to this topic :adapter => 1 I can set my private_network as adapter 1 but then I don't have NAT which I need, so what is, maybe, NAT network identifier?

1条回答
forever°为你锁心
2楼-- · 2019-05-23 10:20

I don't believe you can. It's fundamental assumption that Vagrant makes. Some parts of the code in Vagrant make specific assumptions that eth0 = NAT.

However you might want to try renaming the interfaces after the machine is created.

查看更多
登录 后发表回答