The Germany military's counter-intelligence agency is looking into 275 suspected right-wing extremists in its ranks, including a soldier heard saying "Heil Hitler," the Defence Ministry has told parliament in a letter seen by Reuters on Sunday.

About 143 of the cases were reported last year and 53 this year, the ministry wrote in its 15-page answer, detailing incidents of soldiers performing Nazi salutes or uttering racist remarks against servicemen with migrant backgrounds.

Public displays of Nazi symbols and salutes are illegal in Germany, where most people are repulsed by any degree of sympathy to the dictatorship responsible for the Holocaust.

One such incident is Case 29, which involved a soldier who was heard conspicuously saying "Heil Hitler," "Heil our leader" and "Sieg Heil, comrades," the ministry said.

"The case was passed on to the military prosecutor and the public prosecutor's office, but neither an early dismissal nor a service ban took place," it wrote to parliament.

Another case involved a soldier who used a Facebook page associated with the far-right National Democratic Party (NPD) to spread racist remarks, including demanding the death sentence for "typical foreigners."

Germany's Constitutional Court said in January that the NPD resembled Adolf Hitler's Nazi party but ruled against banning it because it was too weak to endanger democracy.

The ministry said the soldier was "only disciplined."

In a third case, a soldier was allowed to keep his weapon after he was disciplined for performing the Nazi salute while on a trip to the Latvian capital, Riga.

German media reported last year that there are signs Islamists were trying to join the German armed forces to get military training with the possible goal of carrying out attacks in Germany.