Praise be to Allaah.
Firstly:
It is not permissible for a Muslim to keep a dog, unless he needs this dog for hunting, guarding livestock or guarding crops.
Al-Bukhaari (2145) narrated that Abu Hurayrah (may Allaah be pleased with him) said: The Messenger of Allaah (peace and blessings of Allaah be upon him) said: “Whoever keeps a dog, a qiraat from his good deeds will be deducted every day, except a dog for farming or herding livestock.”
Muslim (2978) narrated from Abu Hurayrah (may Allaah be pleased with him) that the Messenger of Allaah (peace and blessings of Allaah be upon him) said: “Whoever keeps a dog that is not a dog for hunting, herding livestock or farming, two qiraats will be deducted from his reward each day.”
Muslim (2943) narrated from ‘Abd-Allaah ibn ‘Umar (may Allaah be pleased with him) that the Messenger of Allaah (peace and blessings of Allaah be upon him) said: “Whoever keeps a dog, except a dog for herding livestock or a dog for hunting, a qiraat will be deducted from his good deeds each day.” ‘Abd-Allaah said: Abu Hurayrah said: Or a dog for farming.
Ibn ‘Abd al-Barr said: This hadeeth shows that it is permissible to keep a dog for hunting and herding livestock, and also for farming.
Ibn Maajah (3640) narrated from ‘Ali ibn Abi Taalib (may Allaah be pleased with him) that the Prophet (peace and blessings of Allaah be upon him) said: “The angels do not enter a house in which there is a dog or an image.” Classed as saheeh by al-Albaani in Saheeh Ibn Maajah.
These ahaadeeth indicate that it is haraam to keep a dog, except for those which were exempted by the Messenger (peace and blessings of Allaah be upon him).
The scholars differed as to how to reconcile between the reports which speak of one qiraat being deducted and those which speak of two qiraats being deducted.
It was said that two qiraats will be deducted if the dog is more harmful and one qiraat will be deducted if it is less so.
And it was said that that at first the Prophet (peace and blessings of Allaah be upon him) said that one qiraat would be deducted, then the punishment was increased after that, so he said that two qiraats would be deducted in order to put people off from keeping dogs even more.
The qiraat is an amount that is known to Allaah, may He be exalted, and what is meant is that some of the reward for a person’s good deeds will be deducted.
See Sharh Muslim by al-Nawawi, 10/342; Fath al-Baari, 5/9
Shaykh Ibn ‘Uthaymeen said in Sharh Riyaadh al-Saaliheen, 4/241:
With regard to keeping dogs, this is haraam and is in fact a major sin, because the one who keeps a dog, except those for which an exception has been made, will have two qiraats deducted from his reward every day.
Secondly:
Is it permissible to keep dogs to guard houses?
Answer:
The Prophet (peace and blessings of Allaah be upon him) made only three exceptions to the prohibition on keeping dogs: hunting, guarding livestock and guarding crops.
Some scholars are of the view that it is not permissible to keep a dog for any reason other than these three. Others are of the view that it is permissible to draw analogies between these three and similar or more likely cases, such as guarding houses, because if it is permissible to keep dogs to guard livestock and crops, it is more appropriate that it should be permissible to keep dogs to guard houses.
Al-Nawawi said in Sharh Muslim (10/340):
Is it permissible to keep a dog to guard houses, alleys and the like? There are two points of view. The first is that it is not permissible, because of the apparent meaning of the ahaadeeth, which clearly state that keeping dogs is forbidden except for farming, hunting and herding. The more correct view is that it is permissible, by analogy with those three cases, knowing that the reason that is understood from the ahaadeeth is necessity. End quote.
The view that was classed as saheeh by al-Nawawi (may Allaah have mercy on him), that keeping a dog to guard the house is permissible, was also classed as saheeh by Shaykh Ibn ‘Uthaymeen (may Allaah have mercy on him) in Sharh Saheeh Muslim. He said:
The correct view is that it is permissible to keep a dog to guard the house, because if it is permissible to keep a dog in order to benefit from it, as in the case of hunting, it is more appropriate that one be allowed to keep a dog in order to ward off harm and protect oneself.
End quote.
Source:
http://www.islam-qa.com/en/ref/69777