Can a Muslim fight in a non Muslim war, like the Afghanistan war or something? I do not know if this is permissible or not.
It is not permissible. Joining non-Muslims in war against Muslims is the clearest form of taking them as allies instead of the believers:
O you who have believed, do not take the disbelievers as allies instead of the believers. Do you wish to give Allah against yourselves a clear case?
O you who have believed, do not take the Jews and the Christians as allies. They are [in fact] allies of one another. And whoever is an ally to them among you - then indeed, he is [one] of them. Indeed, Allah guides not the wrongdoing people.
And in war you will take lives and properties of other Muslims which is forbidden:
O you who have believed, do not consume one another's wealth unjustly but only [in lawful] business by mutual consent. And do not kill yourselves [i.e. one another]. Indeed, Allah is to you ever Merciful. And whoever does that in aggression and injustice - then We will drive him into a Fire. And that, for Allah, is [always] easy.
A Muslim is he from whose hand and tongue the Muslims are safe.
It is not permitted to even give charity or sell weapons to non-Muslims who fight against Muslims, giving them your entire self is far worse.
It can be okay without any special problem in the case that there is no disadvantage for Islam. As you asked if a Muslim can fight in a non Muslim war or not, your answer perhaps depends on the religion of the country. In fact Islam doesn't allow Muslims to fight against other Muslims, just they can defend, not attack. Because Muslims should have unity, otherwise fighting will weak them. you gave the example of Afghanistan, so Afghanistan is an Islamic country, then it is not allowed to attack to Muslims.
It depends on benefit of Islamic Ummah. If it does not harm benefits of Islamic Ummah there is no problem. this is an Islamic State issue and scholars consider different conditions for it. For example if it is at time of a war for Muslims or else. anyway general law is that if it does not harm benefits of Islamic Ummah there is no problem to sell weapons or other services or products to a non-Muslim military.
Reference of Fatwa:
- Tahrir al-Wasilah vol.1 page 496