Dig a moat.

Moats protect castles. They are deep, full of water, teeming with crocodiles, and maybe the skulls of our enemies. Ok, maybe skip that last part about the skulls. The gist is that moats protect the people in the castle from whatever they need protection from... except from maybe flying things like dragons...