diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb index ebdf23516..944bdd5f8 100644 --- a/lib/vagrant/errors.rb +++ b/lib/vagrant/errors.rb @@ -448,6 +448,10 @@ module Vagrant error_key(:not_found, "vagrant.actions.vm.host_only_network") end + class NetworkTypeNotSupported < VagrantError + error_key(:network_type_not_supported) + end + class NFSBadExports < VagrantError error_key(:nfs_bad_exports) end diff --git a/plugins/guests/darwin/cap/configure_networks.rb b/plugins/guests/darwin/cap/configure_networks.rb index 1be71c82f..36487cd08 100644 --- a/plugins/guests/darwin/cap/configure_networks.rb +++ b/plugins/guests/darwin/cap/configure_networks.rb @@ -35,12 +35,19 @@ module VagrantPlugins end network_type = network[:type].to_sym - if network_type == :static - command = "networksetup -setmanual \"#{service_name}\" #{network[:ip]} #{network[:netmask]}" - elsif network_type == :dhcp + case network_type.to_sym + when :static + command = "networksetup -setmanual \"#{service_name}\" #{network[:ip]} #{network[:netmask]} #{network[:router]}" + when :static6 + command = "networksetup -setv6manual \"#{service_name}\" #{network[:ip]} #{network[:netmask]} #{network[:router]}" + when :dhcp command = "networksetup -setdhcp \"#{service_name}\"" + when :dhcp6 + # This is not actually possible yet in Vagrant, but when we do + # enable IPv6 across the board, Darwin will already have support. + command = "networksetup -setv6automatic \"#{service_name}\"" else - raise "#{network_type} network type is not supported, try static or dhcp" + raise Vagrant::Errors::NetworkTypeNotSupported, type: network_type end machine.communicate.sudo(command) @@ -65,7 +72,7 @@ module VagrantPlugins ints = ::IO.read(tmp_ints) ints.split(/\n\n/m).each do |i| if i.match(/Hardware/) && i.match(/Ethernet/) - # Ethernet, should be 2 lines, + # Ethernet, should be 2 lines, # (3) Thunderbolt Ethernet # (Hardware Port: Thunderbolt Ethernet, Device: en1) diff --git a/templates/locales/en.yml b/templates/locales/en.yml index fc3d6245c..d3fa33e13 100755 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -869,6 +869,8 @@ en: If the problem persists, please report a bug to the net-ssh project. %{message} + network_type_not_supported: |- + The %{type} network type is not supported for this box or guest. nfs_bad_exports: |- NFS is reporting that your exports file is invalid. Vagrant does this check before making any changes to the file. Please correct