While there are many tracks on Margallaz that could lead to Khanpur, I personally like the Faisal mosque – Tilhar one. If you have to start from Islamabad and have 6-7 hours to walk, Faisal mosque to Dhuniyyan village trek is the best option.
You can start the trek either from E-7 or from behind the Kuwait hostel of International Islamic University. CDA has marked this trail up to the Tilhar Mor as Trail 4. Surprisingly trails in Margallazs are not numbered sequentially as Trail 3 is in the middle of Trail 5 and 4. Trail 4 starts opposite to the northern end of E-7 from the corner of the road near Jamia Faridia cemetery and the residence of Dr. A. Q. Khan. First 15 – 20 minutes of the trail is a gentle walk that goes almost along the Pir Sohawa road. After around 10 minutes of walk from the start, the path from Kuwait hostel joins it. Some area here has also been fenced probably to stop the wildlife to enter. Continuing the main trail, after crossing a small stream, one comes across a fork from where the straight path joins the main road again. Take the path to the left to continue on Trail 4. From this point, ascend starts and continues for the next hour or so. The ascend becomes mild as the track starts going more along the ridge. For most of the time, one can see the main Pir Sohawa road going in parallel at the far end on the other ridge. In around 2 hours from the start, one should be able to reach at the top of ridge where a marked path to the left goes towards Tilhar View Point. From this point, Tilhar becomes visible with a beautiful view of its field and houses. Total distance covered up to this point is around 8.5 kms. Continuing straight on Trail 4, one can reach the Pir Sohawa road in further 15 – 20 minutes from where Monal restuarant is at a distance of further 5-10 minute walk. From Tilhar View Point, one can descend to the Tilhar village in around 30 minutes. Reach to the eastern side of village where there are a few shops. Continuing on the road, you will reach a wide water stream that is bisecting the village. Cross the village and pass through the houses through a narrow way before the school to reach the road.
From this point, you should be able to see a few houses at the top of ridge in front of you towards west. This is the Kingri village (part of Tilhar village). Keeping those houses in sight, take the path going towards them. Continuing on the track after passing through Kingri, you should be able to reach at a relatively open area near the top of the ridge where one can get a very clear view of Khanpur lake. A jeep track starts after another further 10 minutes of walk from this point. Follow the track and you will reach the village Bakka. You will come across a fork after crossing Bakka. Take the one that is going right and it will take you to the Karwali village. From Karwali, leave the jeep track and drop down to the village from where take another track that is going towards Dhunniyan. From a walk of another 5-10 minutes from the village a Jeep track will join from the left where there is also a small water stream and a place for prayers. If from Kingri, you take a path going left, you will come through this jeep road bypassing the Bakka and Karwali villages. Follow the jeep track for another hour and it will take you to Dhunniyan. The total time it takes from Tilhar to Dhunniyan is around 4 -5 hours. From Dhunniyan, public transport can be taken to reach back to Islamabad via Tarnawa and Taxila.