Minecraft wiki entry for Tips_and_tricks, associated text: A trick to defend the base that works best once the player is settled in, and have enough iron to make at least tracks, and ideally powered rails and a minecart. The simple version is to just ring the house with rails -- mobs will not walk across tracks. However, this will not prevent creepers exploding, skeletons shooting across the rails, or endermen teleporting into your base.