David Mayo didn’t know it then, but the 49ers were doing him a huge favor.

On Aug. 31, he was released by San Francisco. Three days later, he was a Giant. A month later, he’s starting at inside linebacker.

“It worked out great. I love it here,” Mayo said Friday, after fellow inside linebackers Alec Ogletree (hamstring) and Tae Davis (concussion) were ruled out, making him the starter for Sunday’s game against the Vikings at MetLife Stadium. “That’s the way this game goes. You never know when your opportunity is going to come.

“When the Giants called, I was pretty excited,” he added. “It was a good fit and I was happy to come.”

While coach Pat Shurmur didn’t announce his plans, it seems certain Mayo will be the one with the radio receiver in his helmet most of the time, communicating with defensive coordinator James Bettcher and relaying play calls to his teammates. He was the one tasked with that job in the second half of Sunday’s victory over the Redskins, after Ryan Connelly suffered a torn ACL.

“I’ve done it plenty of times. I’m comfortable with it,” said Mayo, who had eight tackles against the Redskins. “I feel good about calling plays and setting the fronts and all that stuff. If it’s me, I’ll be ready.”

Recently signed Nate Stupar and undrafted rookie free agent Josiah Tauaefa will also see time at inside linebacker. But look for the Giants to use more of a three-safety look, with Jabrill Peppers as a hybrid linebacker playing close to the line of scrimmage. They used those packages against the Redskins and had success with them. Peppers also had his best game as a Giant, producing a pick-six.

“Obviously, it gives you a little bit more flexibility to match formations that are unusual. You can match guys a little bit better with that formation,” defensive backs coach Everett Withers said. “It gives you a little bit more flexibility because there are a lot of [defensive backs] on the field, and sometimes [you can identify] where the protection slide gets hard for offenses. It gives us some flexibility to do some things. It also gives us the opportunity to get maybe a little bit of a faster guy, a better matchup coverage wise, on the field.”

Shurmur said there is a “possibility” they could use that more frequently on Sunday. Either way, Mayo will be playing a lot, rarely leaving the field. When the 49ers let him go, it came as a surprise, because he expected them to take six linebackers. Instead, they kept five, and he was the sixth man on the depth chart.

But he wasn’t unemployed long, quickly hearing from the Giants and general manager Dave Gettleman, who drafted him for the Panthers out of Texas State in the fifth round in 2015. Mayo spent the first four years of his career with Carolina, starting a career-high three games a year ago. Now he’ll be in that role again.

“I had to learn this defense really quick,” Mayo said, “so my big thing is I’m just focused on my job, get everybody lined up, play with outstanding effort, physicality and let the cards fall where they may.”