The routes from Madrid and El Escorial to Segovia strike through the heart of the Sierra de Guadarrama (sierranorte.com), and it is a beautiful journey. The road is occasionally marred by suburban development, especially around Navacerrada, Madrid’s main ski station, but from the train it’s almost entirely unspoilt. There are plenty of opportunities for walking, but make sure you buy the appropriate maps in Madrid.
If you want to base yourself in the mountains for a while you’d do best to head for Cercedilla. Alternatively, over to the east, there is Manzanares el Real, with its odd medieval castle and reservoir-side setting.
In the shadow of the mountains to the north lies the Valle de Lozoya. At the western end are the village of Rascafría and the nearby Benedictine monastery of El Paular, and to the east the old fortified town of Buitrago with a medieval core and small Picasso museum.