The idea of a castle circled by a moat has a kind of picture-postcard, romantic allure. In fact, moats were among the most effective defences a castle could have, and were incredibly difficult to construct - sometimes involving the creation of a dam to control how much water was diverted into the moat from a nearby lake or river.
While they weren't actually filled with crocodiles and other deadly creatures, moats did put invaders in a lethally vulnerable position: trying to cross the water would make them easy targets for archers. Just as importantly, moats could stop siege weapons from getting too close, and make it far harder for "sappers" - tunneling soldiers - from digging their way under the castle walls.
The most obvious way to keep would-be killers and invaders from bursting through the chamber door was to erect really thick castle walls. Many medieval fortresses also boasted "curtain walls". Linked by towers, these formed a sprawling outer barrier around the main castle structure.
Some castles had more than one set of curtain walls, so breaching the outer perimeter would merely lead invaders into a "killing field" where they could be picked off by archers stationed on the inner walls. Speaking of which, curtain walls often featured very narrow gaps known as arrow slits or arrow loops, where castle defenders would crouch and fire their lethal projectiles.
Some castle builders went one better when designing the outer walls. They would add a "talus", which is a vast sloping face at the base of the walls. While this resulted in structures that are less pretty and fairy tale-like to modern eyes, the talus formations played a big defensive role.
Invaders would find it difficult to scale a talus - siege equipment like battering rams would be made useless, and scrambling over a talus would make soldiers even more vulnerable to arrows and stones being hurled by those within. In fact, rocks would be deliberately dropped onto the talus so they'd break apart into a shower of shrapnel, right over the heads of the enemy fighters.
Think "castle" and battlements are probably one of the first things that come to mind. These teeth-like structures running along the tops of walls and towers are the most iconic architectural feature of medieval fortresses, thanks to films and stories, which have them patrolled by sentries and archers.
Battlements were indeed used as vantage points and sheltered posts by castle guards but rather less well-known are the names given to the separate sections of battlement. The jutting "tooth" bits are known as merlons, while the flat spaces in between are crenels. It was through the crenels that weapons were fired at the enemy, although merlons sometimes featured their own arrow slits as well.
If the invading troops somehow managed to get past the outer perimeter and breach the entrance of the castle itself, they might still run afoul of some colourfully named defensive adornments: "murder holes". As the name implies, they consisted of holes in the ceilings of gateways and passageways through which defenders could literally rain death down on invaders.
There's a popular idea that hot oil would often be poured down murder holes, but this is most likely a myth. Oil was too precious a commodity to be used as a weapon. Instead, castle defenders would most likely drop down rocks, boiling water and of course arrows onto unwary heads. Exterior variations of murder holes were "machicolations", or openings in the arching stone supports underneath jutting battlements.