diff --git a/plugins/providers/virtualbox/action/network.rb b/plugins/providers/virtualbox/action/network.rb index efa5929d3..13342932a 100644 --- a/plugins/providers/virtualbox/action/network.rb +++ b/plugins/providers/virtualbox/action/network.rb @@ -302,6 +302,9 @@ module VagrantPlugins elsif ip.ipv6? options[:netmask] ||= 64 + # Append a 6 to the end of the type if it is not already set + options[:type] = "#{options[:type]}6".to_sym if + !options[:type].to_s.end_with?("6") else raise IPAddr::AddressFamilyError, 'unknown address family' end diff --git a/test/unit/plugins/providers/virtualbox/action/network_test.rb b/test/unit/plugins/providers/virtualbox/action/network_test.rb index f71ceaab2..79e5a7535 100644 --- a/test/unit/plugins/providers/virtualbox/action/network_test.rb +++ b/test/unit/plugins/providers/virtualbox/action/network_test.rb @@ -62,6 +62,28 @@ describe VagrantPlugins::ProviderVirtualBox::Action::Network do expect(subject).to receive(:validate_hostonly_ip!) subject.hostonly_config(options) end + + context "when address is ipv6" do + let(:address) { "::1" } + + context "when type is static6" do + let(:type) { :static6 } + + it "should have a static6 type" do + result = subject.hostonly_config(options) + expect(result[:type]).to eq(:static6) + end + end + + context "when type is static" do + let(:type) { :static } + + it "should have static6 type" do + result = subject.hostonly_config(options) + expect(result[:type]).to eq(:static6) + end + end + end end describe "#validate_hostonly_ip!" do