Allah bless the shaheed.
I'm sorry but base security needs a massive overhaul, as attackers shouldn't be able to get past the first line of defence. Small radar systems to detect incoming threats, then Steel walls, after-which there is razor wire, then guard towers armed with gatling guns, behind which are patrols with IFV's.
With all due respect
1) Pakistan economy is not in such a good shape to provide state of the art fencing on Afghanistan border. And that would not be feasible as well. Look at loc, it's roughly 700 km and takes a heavy toll on indo-Pak economies and here we are talking about more than 2000 km of rough terrain.
2) completely closing the border is not an option as well neither it's possible. Section of communities won't allow that in Pakistan. Even if it does get done, what stops a terrorist with about 5 kg of rdx to blow a hole in that fence. No country can monitor that big a fence in real time.
3) another point raised in this thread by others and here by you is to provide adequate security measures to establishment like bases and etc. I don't think that's feasible as well. There are N number of possible targets for terrorists. How many cab you provide 3-4 layer security with. Even if you provide all the establishment with high level security, that doesn't solve the problem
Does it?
Terrorists can always go for softer targets like markets and mosques and for example schools. You can not provide security to every living soul in Pakistan. How many APS can you give 3 layer security? How many mosques cab you guard with a number of soldiers? How many markets can you patrole with fully equipped battle ready soldiers?
There will always be a possible target available for terrorists.
4) In my opinion, the best way to stop these terror attacks is counter intelligence. It's cheaper than putting fences and patrolling mosques and markets. And it gets the job done with minimum collateral.
For example, look how indian army curbed terrorists in kashmir. They infiltrated terrorists organisation and made deep assets in them. They started getting useful information on terror hideouts, sleeper cells, possible attacks etc. Some assets even got used in tearing terror organisations in numbers.
A solution is always there in history. If you read similar problems from around the world, and successful solutions then you will definitely get an idea as to how to tackle this problem.
For example
Israel with Hamas.
CIA with Mexican drug Lords.
Chinese with Tibetan.
However my analogies may not be exact, but carefully studying these will definitely give you some idea.