Moat

A moat is useful at keeping people or plague infected animals from getting too close to your home or community.

If raiders made used scrap metal to armor a bulldozer and came at you, a dry or wet moat would be useful at stopping them.

If anyone tries to sneak over to you, having a moat filled with alligators, snakes, toxic waste, or whatever, would help discourage them.

You can grow thorny plants at the bottom of a moat, or leave dangerous animals.

Alcohol floats on water, so you can pour it over a moat and then light it on fire to burn anyone trying to come across by swimming or boats.

Making quicksand for a moat should work well as well.