PABRADE, Lithuania — If a shooting war ever breaks out between Russia and the NATO alliance, it could well be in a place like Pabrade, a little town near the edge of a little nation. But a different sort of conflict, waged with bytes rather than bullets, is already being fought here.

Jim Mattis, the American secretary of defense, visited this Lithuanian town on Wednesday to see how NATO is faring in that fight, and his guide was a German officer who has been a target in that war, falsely accused of being a rapist and a Russian spy.

“What’s the spirit of your troops?” Mr. Mattis asked, walking past camouflaged tanks as soldiers with green-painted faces stood at attention.

He was assured by his guide, Lt. Col. Christoph Huber, commander of the German battalion that recently took up station here, that morale could not be higher.