diff --git a/lib/vagrant/action/vm/nfs.rb b/lib/vagrant/action/vm/nfs.rb index cadb645b9..0fcb91253 100644 --- a/lib/vagrant/action/vm/nfs.rb +++ b/lib/vagrant/action/vm/nfs.rb @@ -132,12 +132,17 @@ module Vagrant # # @return [String] def host_ip - interface = @env[:vm].vm.network_adapters.find do |adapter| - adapter.host_interface_object + @env[:vm].driver.read_network_interfaces.each do |adapter, opts| + if opts[:type] == :hostonly + @env[:vm].driver.read_host_only_interfaces.each do |interface| + if interface[:name] == opts[:hostonly] + return interface[:ip] + end + end + end end - return nil if !interface - interface.host_interface_object.ip_address + nil end # Returns the IP address of the guest by looking at the first @@ -145,7 +150,13 @@ module Vagrant # # @return [String] def guest_ip - @env[:vm].config.vm.network_options[1][:ip] + @env[:vm].config.vm.networks.each do |type, args| + if type == :hostonly && args[0].is_a?(String) + return args[0] + end + end + + nil end # Checks if there are any NFS enabled shared folders. @@ -161,7 +172,7 @@ module Vagrant def verify_settings raise Errors::NFSHostRequired if @env[:host].nil? raise Errors::NFSNotSupported if !@env[:host].nfs? - raise Errors::NFSNoHostNetwork if @env[:vm].config.vm.network_options.empty? + raise Errors::NFSNoHostNetwork if !guest_ip end end end diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 4b6ca6a02..a80e0d589 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -450,8 +450,9 @@ en: are auto-detected, but can be overridden with `config.vagrant.host`. There is currently no host class loaded. no_host_network: |- - NFS shared folders requires that host only networking is enabled. - Please enable host only networking via `config.vm.network`. + NFS shared folders requires that host only networking is enabled + with a static IP. Please enable host only network and assign a + static IP via `config.vm.network`. not_supported: |- The host class is reporting that NFS is not supported by this host, or `nfsd` may not be installed. Please verify that `nfsd` is installed