It is a well known fact, that Afghanistan has almost no railroads. The Soviet Army traditionally relies on one, so building logistics on wheels turned out to be a challenge. Especially given the mountain area and hostile locals. The number of armored vehicles assigned to logistical columns was limited, as most were used for other operations. As usual, troops had to improvise.
Brief overview of Soviet logistics in Soviet-Afghan war
As argued by my favorite military author - "War is all about logistics". And it is hard to disagree with this narrative - even the bravest, most skilled and well trained unit will be dismantled by lesser foe, if the first one is cut off the supplies for too long.
And even thought Soviet Army had no need for excessive amounts of war supplies, due to limited use of artillery, the Soviet Contingent in Afghanistan still consisted of four complete divisions, dozens of separate brigades and regiments and numerous units, battalions and separate companies. All these people would need resources to maintain their everyday life.
Soviet logistics was based primarily on two units - 58th Automobile Brigade and 59th Material Support Brigade. On top of that, every division had its own material support battalion and every brigade had a logistics company.
Attacks on supply columns
It is obvious, that long columns on narrow roads had become perfect targets for the Afghan Mujahedeen. These were overall perfect targets. It was easier to fight against supply troops in comparison to infantry units and it was way more practical. Apart from destroying Soviet supply, Mujahadeens had a chance to capture some materiel for themselves.
Soviet Army introduced two main tactical moves to protect their supply lines against such attack - we can call them static and dynamic. By static tactics I mean a huge number of Soviet Army outposts, which were conveniently placed on the hills and rocks alongside the main roads. In theory, they were suppose to control the region around them. Yet, since their reconnaissance capabilities were crippled and firearms capabilities were usually limited to 12.7mm Machine gun or a single mortar, they could only do so much. Not to forget the constant lack of personnel on such outposts.
The second approach was more aggressive and it is likely that it was decided on local level, rather than by the HQ. The installation of powerful firearms on the back of the supply tracks was as useful as it gets - supply columns finally get some protection against their offenders.
Problems with the standard Soviet armored vehicles
This topic is actually quite broad and needs an article of its own. In short, at the beginning of the Soviet-Afghan war, almost all Soviet fighting machines were incapable of elevating their main gun high enough to be able to engage ambushing Mujahadeens. BMP-1, BMD-1, BTR-60/70 were not good for this task. Because of this, the development and adoption of BMP-2 and BTR-80 was accelerated. Yet, in 1980 there was no adequate means to protect columns and so soldiers did everything themselves.
On top of that, it was not always possible and comfortable to get proper fire support from the fighting units - they were all engaged with their own tasks.
The classical gunracks, widely known to public from the Vietnam War, soon became a thing in the Soviet Army in Afghanistan. Despite being against any regulations, supply officers encouraged such developments and participated in them.
Typical trucks variants and their armament
The choice for the truck was dictated by the availability. Whatever was used by the unit, would be used to make an improvised fighting vehicle. There were four main trucks used by the Soviet Army - GAZ-66, KaMAZ, ZIL-130/131 and Ural-4320.
The choice for the armament was dictated by elevation capabilities and availability of the weapon system. The absolute winner was a well known ZU-23-2 Anti-aircraft gun. It was one of the most common anti-air weapon system in the Soviet Army, so it was widely available to most units.
And since there were no air targets for the anti-air units, they were soon attached to the supply columns to protect them, now on official level. This made ZU-23-2 most used gun to protect the columns. And there are tons of photos to prove this.
However, this was not the only weapon system installed on gunracks. Another popular option was the 12.7 Heavy machine gun, notably DShK, as it had high elevation level with the standard tripod.
Another way to improve the firepower was to install the hanging block of the uncontrolled rockets from the helicopter armament. This was, of course, subject to availability and I believe that the effects of such unprecise fire were somewhat questionable.
There were some other weapons, installed on Soviet-Afghan war era gun tracks, but they were really exceptions rather than a rule. You can see them on the attached photos.