Tension has flared on the border between Pakistan and Afghanistan after the two sides exchanged artillery and machine-gun fire .