Military spokesman David Obonyo said two Kenyan soldiers were also killed and five others wounded when Shebab militants laid an ambush in Afmadhow, southern Somalia, yesterday.
"21 Shebab militants were killed," Obonyo said, during what he described as a "fierce engagement". Last week, the Kenyan army said it thwarted an attack on a military camp also at Afmadhow, killing 19 militants.
In January, the Al Qaeda-aligned Shebab overran a Kenyan military camp in El-Adde manned by up to 200 soldiers, killing a large number of them although Nairobi has refused to say how many died.
The attack, which was widely regarded as Kenya's worst-ever military loss, was the third major assault on isolated bases manned by soldiers of the multi-country African Union Mission in Somalia (AMISOM).
Since then, AMISOM forces have withdrawn from a number of towns in southern Somalia. Earlier this month, the US said it carried out an airstrike on a Shebab training camp north of the Somali capital Mogadishu killing 150 fighters, a figure disputed by the insurgents.
The Shebab was ousted from Mogadishu in August 2011 and has since lost much territory. Today, it concentrates on guerrilla attacks in the Somali countryside, bombings and suicide raids in towns and cities, and terror assaults in Kenya.
Shebab fighters have targeted AMISOM because, in the absence of a functioning national army, the 22,000-strong force is the only protector of the internationally-backed government that the jihadists are committed to overthrowing.