Coach Carlo Ancelotti admitted recently he was keen on the Brazilian right-back and Madrid have moved to tie up a deal for around €25m.
Danilo, who was stretchered off in Porto's 4-0 win over Basel in the Champions League on Tuesday night, will compete with Dani Carvajal for the right-back spot at the Santiago Bernabeu next season, with Alvaro Arbeloa set to leave the club.
The 23-year-old, who will sign a five-year contract, was also a target for Barcelona as the Catalan club seek a long-term replacement for Brazil defender Dani Alves. The former Sevilla right-back is out of contract in the summer and looks set to leave the Camp Nou outfit after seven seasons with the Blaugrana.
Barca's transfer ban means they would not have been able to play Danilo until 2016 even if they had managed to sign the player this summer and that uncertainty seems to have convinced the full-back to link up with international team-mate Marcelo at the Bernabeu.
"I like Danilo, but I like a lot of players in Europe," Ancelotti said last week. "We are not thinking of transfers at the moment."
However, Porto team-mate Jose Angel claimed last month that Danilo is ready to make the step up and join Madrid.
Meanwhile, former Barca midfielder Carles Rexach, now an advisor at the Catalan club, admitted earlier this week that Madrid were winning the battle to sign the right-back.
"I have been told that Danilo has been signed by Real," the 68-year-old told Esport 3 on Monday.