Magistrate Judge David J. Novak reminded the former first couple multiple times that the punishment for breaking those rules could be jail time.
"If you do that, the government is going to find out," Novak said.
The McDonnells have denied charges they illegally accepted more than $165,000 in loans and gifts from a former CEO of a dietary supplement-maker in return for promoting his products. Their trial is set to begin in July.
Monday's hearing followed a set-to last week between prosecutors and the McDonnells' attorneys over a typically routine gag order prohibiting defendants from making contact with potential witnesses.
Prosecutors argued in court records that the McDonnells should be allowed to speak only with potential witnesses who are family members, and not about the case.
The McDonnells' lawyers argued that the prosecutors were seeking "draconian" restrictions that would prevent the McDonnells from accessing their support network during an "extremely traumatic" period in their lives.
Novak ruled that the McDonnells could speak with any potential witness about benign aspects of the case — such as scheduling issues — but could not discuss anything "about the substance of the case." The order excludes so-called character witnesses who would not be testifying about aspects of the criminal case.
In court, Bob McDonnell's attorney unsuccessfully argued for slightly fewer restrictions, with prohibited conversations limited only to potential witnesses' possible testimony.
At Monday's hearing, Novak said he had no reason to believe the McDonnells would not comply with his rules but warned them that their former high-ranking positions would not exempt them from punishment.