diff --git a/libmachine/provision/generic.go b/libmachine/provision/generic.go
index <HASH>..<HASH> 100644
--- a/libmachine/provision/generic.go
+++ b/libmachine/provision/generic.go
@@ -46,8 +46,15 @@ func (provisioner *GenericProvisioner) SetHostname(hostname string) error {
 	}
 
 	// ubuntu/debian use 127.0.1.1 for non "localhost" loopback hostnames: https://www.debian.org/doc/manuals/debian-reference/ch05.en.html#_the_hostname_resolution
-	if _, err := provisioner.SSHCommand(fmt.Sprintf(
-		"if grep -xq 127.0.1.1.* /etc/hosts; then sudo sed -i 's/^127.0.1.1.*/127.0.1.1 %s/g' /etc/hosts; else echo '127.0.1.1 %s' | sudo tee -a /etc/hosts; fi",
+	if _, err := provisioner.SSHCommand(fmt.Sprintf(`
+		if ! grep -xq .*%s /etc/hosts; then
+			if grep -xq 127.0.1.1.* /etc/hosts; then 
+				sudo sed -i 's/^127.0.1.1.*/127.0.1.1 %s/g' /etc/hosts; 
+			else 
+				echo '127.0.1.1 %s' | sudo tee -a /etc/hosts; 
+			fi
+		fi`,
+		hostname,
 		hostname,
 		hostname,
 	)); err != nil {
issue #<I>, If a permanent IP address and hostname has alread in /etc/hosts