The usual plan was to build towers on either side of the entrance, with the way into the castle in a tunnel between them.
Entrance ways were often full of traps. Moats had to be crossed by drawbridges which could be pulled up from inside the gatehouse. Very few are left in place, but at Caernarvon and Caerphilly for example you can see where the drawbridges once were.
As well as strong timber and iron studded doors, there were portcullises, which dropped down from slots in the wall above. Above the entrance and in the roof of the tunnel, there were often murder holes, through which defenders could shoot down or drop things onto an enemy.
In the walls, inside and out, there were slit windows for archers to shoot through.
There was another use for a strong gatehouse. Sometimes a lord did not trust some of his own soldiers. With his family and a few trusted men, he could defend a gatehouse against attacks from inside as well as outside the castle.
© Dial Solutions 2000