Sahih Muslim 1573b
Ibn Mughaffal reported: Messenger of Allah ﷺ ordered the killing of dogs and then said: what is the trouble with them (the people of Medina)? How dogs are nuisance to them (the citizens of Medina)? He then permitted keehing of dogs for hunting and (the protection of) herds. In the hadith transmitted on the authority of Yahya, he (the Holy Prophet) permitted the keeping of dogs for (the protection of) herds, for hunting and (the protection of) cultivated land.
حَدَّثَنَا عُبَيْدُ اللَّهِ بْنُ مُعَاذٍ، حَدَّثَنَا أَبِي، حَدَّثَنَا شُعْبَةُ، عَنْ أَبِي التَّيَّاحِ، سَمِعَ مُطَرِّفَ، بْنَ عَبْدِ اللَّهِ عَنِ ابْنِ الْمُغَفَّلِ، قَالَ أَمَرَ رَسُولُ اللَّهِ ﷺ بِقَتْلِ الْكِلاَبِ ثُمَّ قَالَ " مَا بَالُهُمْ وَبَالُ الْكِلاَبِ " . ثُمَّ رَخَّصَ فِي كَلْبِ الصَّيْدِ وَكَلْبِ الْغَنَمِ .