As far as the farm goes, if you tell a pet to stay in an outdoor area it will attack anything that attacks it. It may not survive the encounter if its a low level, but a maxed out dog can wreck just about anything (I did lose one of mine to a chaos, no idea how big it was though)
for home defense they’re not really great for home protection unless the person broke your wall down to get in there and has latent infamy for a bit, it wouldn’t be hard to avoid getting attacked here though if they just run the infamy off.