"We are prepared to take further appropriate measures if there are additional efforts to impede our diplomatic and consular activities in Russia," spokesman Mark Toner warned.
Russia's foreign ministry expressed outrage at the move against the consuls -- US nationals who represent Moscow in California, Utah, Minnesota, Florida and Puerto Rico.
Spokeswoman Maria Zakharova accused US "security services" of carrying out "provocations against employees of Russian diplomatic missions, and not only in the United States."
The State Department said formal diplomatic relations would not be hurt by Washington's tit-for-tat move, which it said followed similar action by Moscow against US interests.
More From This Section
"This action is being taken in response to continued Russian interference with our diplomatic and consular operations in Russia, including, but not limited to, widespread harassment of our personnel, as well as the forced closure of the American Center in Moscow and 28 American Spaces throughout Russia," Toner said.
"They have done similar activities in US mostly targeting
Noting that these are government sponsored groups, Porter said given Russian cyber capabilities and its damaging potential retaliation is not an option.
"I do not think responding to Russian Government actions would make the problem go away. It would make it worse. I would urge both sides to reach a peaceful diplomatic solution," he said.
Retaliation, he warned, would lead to a lot of collateral damage.
"Individuals, companies and countries that are not directly involved would suffer some of the damage from those cyber-attacks," he said but refused to comment on the US Government policy.
"Hacking back against the Russians carries a significant risk that would lead to a greater and greater conflict. It would not have the hacking go away. The Russians have much better technical capabilities than they have shown so far and can do much greater damage that they have done so far. Because they would see hacking back and activity that they need to respond to," he warned.
"So they probably think, of these cyber operation as their opportunity to counter attack. The activities that has been in happening in the US elections from the Russian perspective are counter-attack. So, if they are hacked backed, that would lead to another random attack by the Russians," he said.
"I don't think, democracies like the US and India want countries to settle their differences by attacking each other's elections. That is not a good precedent for democracy," Porter said.