Their nationalities are not known.
The incident occurred early on Wednesday in Helmand province. Soldiers returned fire killing the attackers, a coalition spokesperson said.
There have been dozens of "green-on-blue" attacks in which Afghan security personnel have targeted their Western allies since 2007.
No group has said it carried out the latest attack.
Insider attacks - on international and Afghan forces - have became one of the gravest security threats of the later phase of the conflict in Afghanistan, although the rate of such incidents has dropped in recent years. More than 100 foreign soldiers have been killed.
Nato has adopted special security measures to offset the threat.
The alliance ended its combat mission in Afghanistan in December, withdrawing most of its troops apart from a 13,000-strong residual force used for training and counter-terrorism operations.
One of the worst insider attacks took place last August when a US general was killed in an attack by an Afghan soldier at a British-run military academy near Kabul.
US Major General Harold Greene was the most senior American military officer to die in action overseas since the Vietnam War.
Many insider attacks are blamed on Taliban infiltration or arguments between foreign and local soldiers getting out of hand.
In some cases such attacks are carried out by an individual - or individuals - acting on their own initiative rather than organised insurgency violence.
The Taliban have stepped up their summer offensive despite an acrimonious leadership dispute following the death of their long-time leader Mullah Omar.
Two people in Afghan military uniforms opened fire on a vehicle killing two Nato soldiers at a military base in the south, alliance officials say.