diff --git a/plugins/guests/darwin/cap/change_host_name.rb b/plugins/guests/darwin/cap/change_host_name.rb index ad7242c91..c65c32642 100644 --- a/plugins/guests/darwin/cap/change_host_name.rb +++ b/plugins/guests/darwin/cap/change_host_name.rb @@ -6,7 +6,9 @@ module VagrantPlugins if !machine.communicate.test("hostname -f | grep '^#{name}$' || hostname -s | grep '^#{name}$'") machine.communicate.sudo("scutil --set ComputerName #{name}") machine.communicate.sudo("scutil --set HostName #{name}") - machine.communicate.sudo("scutil --set LocalHostName #{name}") + # LocalHostName shouldn't contain dots. + # It is used by Bonjour and visible through file sharing services. + machine.communicate.sudo("scutil --set LocalHostName #{name.gsub(/\.+/, '')}") machine.communicate.sudo("hostname #{name}") end end