The solution to random ducks is elephants.
It is not well known, except to experts on the two animals, that the natural enemy of ducks is, indeed, elephants.
If an elephant sees a wandering duck, the elephant will attempt to stamp on it.
After a couple of close calls, even the dumbest duck will stay out of sight when the elephants are around.
You will need an elephant for each story of the house as elephants are afraid of stairs.
Now, if the elephants become a problem, I have a solution for that.
In, one word, monkeys with gongs.
(that's actually three words but you know what I mean.)