U.S. citizen as foreign soldier?

I’ve heard differing views about US citizens being soldiers in a foreign army. One is that you can serve as a non-com, not an officer. Another is that it is completely illegal and can face multiple charges including treason. Who’s got the straight dope?

From a U.S. Department of State website:

If you think about it, U.S. citizens regularly serve with the Israeli Defense Forces.

That’s what I love about this place. Quick, accurate answers. Thanks.

My best friend, an American citizen, served with the Canadian Armed Forces for eight years (1987-1995), joining before he became a dual citizen (holding only U.S. citizenship.) He wrote the the State Department, and got a letter assuring him we would remain a U.S. citizen. A few years ago he moved back to the States and nobody gave him a problem over it.

Both Canada and Israel are US allies. What if my neighbor goes to China or Russia, serves in their army and comes back to the USA. Will he spend time in a Federal court or prison?

Russia’s one of our allies now. The Soviet Union no longer exists.