Sayyiduna Abdullah bin Umar (may Allah be pleased with him) said that the Messenger of Allah (peace and blessings be upon him) ordered us to kill all dogs except dogs for guarding livestock and hunting dogs. It was said to him: "Sayyiduna Abu Hurayrah (may Allah be pleased with him) also exempts the farm dog?" He said: "He had farmland." (Sahih Muslim) And Abu al-Hakam Imran bin al-Harith also narrated from Sayyiduna Ibn Umar (may Allah be pleased with him) the exemption of the farm dog; it is as if he took the matter of farmland from Sayyiduna Abu Hurayrah (may Allah be pleased with him) from the Prophet (peace and blessings be upon him), while Sayyiduna Abdullah bin Umar (may Allah be pleased with him) himself narrated from the Prophet (peace and blessings be upon him) concerning the dog for guarding livestock and the hunting dog.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب البيوع / 11028