Bernard Madoff’s niece and another relative — worried they’ll wind up behind bars — have contacted a consultant who teaches white-collar criminals how to survive in federal prison and secure early release, sources said.

PAGE SIX: Ruth Madoff Barred From Hair Salon

A jail cell would be a stark change for Shana Madoff, who grew up on a six-acre Woodbury, LI, estate called Hastings Hall owned by her parents, Peter and Marion Madoff. Peter is Bernie’s brother.

Shana, 38, who was a compliance officer with the infamous Madoff firm, contacted Larry Levine, a former federal prisoner and founder of Wall Street Prison Consultants, the sources said.

Levine refused to identify his clients, but admitted that “a female relative of Bernie Madoff contacted me” about taking his Fedtime 101 crash course. Shana contacted the company two weeks ago “because she was concerned about her safety” should she ever go to jail, one source said.

Shana “has been asking around what it’s like to do time,” another source said.

That source said she had contacted Levine “to learn how to game the system, so you end up in Club Fed, not Leavenworth.

“Shana was a compliance officer and signed a lot of documents, saying they were correct,” the source said. “She may have a problem.”

Levine said, “Another male member of Madoff’s family also contacted me, independently” on the same subject.

He said a representative of Bernard had contacted him before the Ponzi scammer went to jail, but the rep’s lawyers declined to let him take the course because his phone chats were being monitored. None of the Madoffs has yet sent money to Levine, he said.

“I give people a wakeup call,” said Levine, who is still on federal supervised release after serving 10 years behind bars for counterfeiting securities. His course, which costs $850, also coaches future inmates on how to secure early release.

Shana did not return calls.

Meanwhile, a pair of Bernie’s Mets tickets for today’s home opener at Citi Field fetched $7,500 in an online auction that ended with all the drama of a walk-off home run.

The price soared in the eBay auction’s final minutes, nearly doubling the $3,800 price listed just two hours before the 10 a.m. close, when a war broke out between two rival bidders.

Additional reporting by Leonard Greene

kieran.crowley@nypost.com