Soldiers and police would "go after the groups terrorising innocent people all over the country", he said.
The raids are seen as the biggest security threat facing Nigeria after the Islamist-led insurgency.
Nomadic herders from the Fulani ethnic group and farming communities often clash for control of land and water.
The announcement comes after national outrage over the killing of at least 20 people on Monday in a raid on the Ukpabi Nimbo community in south-eastern Enugu State.
In a statement, Mr Buhari said he deeply sympathised with those who had lost their lives.
He had ordered Nigeria's army and police chiefs to "secure all communities under attack by herdsmen", Mr Buhari added.
"This government will not allow these attacks to continue," the president said.
In February, about 300 people were killed and tens of thousands left homeless in a tit-for-tat raid in central Benue state, local media reported.
Homes, food stores and churches were also destroyed, reports said.
More than 1, 200 people were killed in 2014 by different groups of Fulani herders, according to the Global Terrorism Index.
The Fulanis are believed to be largest semi-nomadic group in the world and are mainly based in West and Central Africa.
In Nigeria, there are two types: The semi-nomadic herders and those who live in the city.
Unlike the more integrated city dwellers, the nomadic groups spend most of their lives in the bush and are the ones largely involved in these clashes.
They herd their animals across vast dry hinterlands, something that often puts them at odds with many communities, especially farmers who accuse them of damaging their crops.
However, the Fulanis have sometimes been attacked and have their animals stolen by bandits, prompting reprisal attacks.
The conflict has been going on for about two decades, but following the upsurge in attacks this year the government is under increasing pressure to take steps to curb it.