Speaking at Prime Minister's Questions, he said to MPs "we have all been guilty" of leading campaigns against them in the past.
But he said the focus should be on "ensuring everyone is connected to the information super highway".
His comments prompted speculation a law change could be in next week's Budget.
The issue was raised by Conservative MP Andrew Murrison, who said the UK's superfast broadband connectivity was "relatively poor" and businesses in rural areas, in particular, were losing out from patchy coverage.
The PM said the number of homes able to access superfast broadband - defined as providing download speeds in excess of 24 Mbps - had doubled since 2010. But he said more needed to be done, suggesting objections to new masts motivated by so-called Nimbyism had to stop.
"I think this is something for members right across the House. Ten years ago we were all rather guilty of leading campaigns against masts and the rest of it," he said.
"Our constituents now want coverage for the internet, they want coverage for mobile phones.
"We need to make sure we change the law in all the ways necessary to make sure... the masts are built, we increase coverage and we ensure everyone is connected to the information superhighway."
The government says it is on track to meet its goals of providing superfast broadband coverage to 90% of the UK by early 2016 and 95% by December 2017 although critics have accused ministers of moving the targets to guarantee compliance.
David Cameron has vowed to change the law so more mobile phone masts can be built to boost broadband and tackle "not spots", especially in rural areas.