The 49ers' defense will line up across from Peyton Manning and the Denver Broncos in the teams' third game of the 2012 preseason.
The Raiders will play their exhibition opener against the Dallas Cowboys in front of a national TV audience.
The NFL released its preseason schedule Wednesday, with ESPN set to televise the Raiders' first game Aug. 13, a Monday night, at O.co Coliseum. Dennis Allen will make his debut as Raiders coach.
The 49ers travel to Denver on Aug. 26 to play the Broncos and Manning, whom the 49ers courted this offseason before his free-agent signing with Denver. That game will be nationally televised on FOX.
The 49ers open the preseason at home against the Minnesota Vikings and travel to Houston to play the Texans in Week 2. Just four days after they play the Broncos, the 49ers wrap up their preseason schedule at home against the San Diego Chargers.
After Dallas, the Raiders will visit the Arizona Cardinals, host the Detroit Lions and play at Seattle to finish the preseason.
Notably, the Raiders and 49ers won't play each other after fan violence marred last August's preseason game at Candlestick Park.