MOSCOW — Russian lawmakers voted on Tuesday to prohibit the country’s troops from using smartphones or recording devices, or posting anything online about their military service, after journalists used soldiers’ digital traces to reveal actions the Kremlin wanted to keep secret.

In recent years, pictures, videos and social media posts put online by Russian servicemen contradicted the government’s claim that its troops were not fighting in eastern Ukraine and undercut the official line that Russia’s role in the Syrian civil war was limited.

The bill’s explanatory note specifically mentions Syria, saying that the analysis of Russian actions there revealed that “military servicemen are of special interest to special services of several states, to terrorist and extremist organizations.”

“Information, shared by soldiers on the internet or mass media, is used for informational and psychologic pressure and in separate cases to form a biased assessment of Russia’s state policy,” said the note, signed by Deputy Defense Minister Nikolai A. Pankov.