diff --git a/regenerate_hosts.sh b/regenerate_hosts.sh
index 6c595526a5b86e0a9bddae7a9276d549f8fe295e..1f6f2718b3211be1fb96871996d6cc4311d662d3 100755
--- a/regenerate_hosts.sh
+++ b/regenerate_hosts.sh
@@ -1,6 +1,8 @@
 #!/bin/bash
 BASE_MACS="6c:4b:90 a4:1f:72 78:45:c4 64:00:6a b0:83:fe d4:be:d9 00:23:24"
 arg="c8:1f:66"
+registry="/etc/registry/hosts"
+cp $registry $registry.bak
 for mac in $BASE_MACS
 do
     arg="$arg\| $mac"
@@ -11,11 +13,14 @@ for line in $(grep "$arg" /var/lib/dhcp/dhcpd.leases | sort -u)
 do
     if [ "$line" != "hardware" ] && [ "$line" != "ethernet" ]
     then
-        MACS="$MACS $(echo $line | sed 's/;$//g')"
+        if [ -z "$(grep $line $registry)" ]
+        then
+            MACS="$MACS $(echo $line | sed 's/;$//g')"
+        fi
     fi
 done
 for mac in $MACS
 do
-    echo "20191025 $mac inconnuAutoGen" >> /etc/registry/hosts
+    echo "20191025 $mac inconnuAutoGen" >> $registry
 done
 systemctl restart registry wakeonlan