The nearest railway stations to the Beacons, unfortunately are miles away from the main walking areas.
Merthyr Tydfil is a good twelve miles from the main Central Beacons of Pen Y fan, and Abergavenny is some distance from Llanthony and Crickhowell.
Another aspect of the Beacons, are the infrequent buses from Brecon to Merthyr.
I lived fairly close to the Beacons, and never really thought about the logistics of walking without ones own transport.
You would be better of hiring a car, and driving to the hills, it will be a lot quicker.