Vagrant (Vagrantfile) で デフォルト の LAN を指定する

状況

複数の NIC がある場合、$ vagrant up した際に、どの NIC を bridge するかを対話形式で以下のように問われます。

$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'ubuntu/bionic64' is up to date...
==> default: Fixed port collision for 22 => 2222. Now on port 2200.
==> default: Clearing any previously set network interfaces...
==> default: Available bridged network interfaces:
1) eno1
2) eno2
3) docker0
==> default: When choosing an interface, it is usually the one that is
==> default: being used to connect to the internet.
    default: Which interface should the network bridge to?

選ぶ NIC が決まっているならばこの対話を省くことができます。

方法

Vagratfileconfig.vm.networkbridge という引数をとってあげます。

(省略)
  config.vm.network "public_network", bridge: 'eno1'
(省略)

参考

Powered by はてなブログ