There was no immediate comment from government officials about the attack on the base in Baar Sanguni, about 50 km from the port city of Kismayu.
"We first attacked the base with a suicide car bomb and then stormed," said Abdiasis Abu Musab, al Shabaab’s spokesman for military operations. "We killed 27 soldiers and took the base. Some soldiers fled into the jungles."
The military was sending reinforcements to the base following the reports of an explosion and heavy fighting after the rebel attack, one official said.
"We have sent reinforcement to the base," Majo Mohamud Aden, a Somali military officer, told Reuters from Kismayu.
"We understand there was an explosion and heavy fighting between al Shabaab, who attacked the base, and the Somali forces. We have no details so far."
Residents of the town of Jamame, 70 km from Kismayu, said they heard the blast, followed by gunfire.
"We heard a huge blast after early morning prayers. Then heavy exchange of gunfire followed. It was in the direction of Baar Sanguni," Osman Abdullahi said.
The attack follows a June attack on the base by al Shabaab that wounded seven soldiers. The group is battling to topple the central government and impose its rule based on its own strict interpretation of Islam’s sharia law.