Electronic structure calculations are used to study the magnetic properties of MnN and Mn3N2. The magnetic moments originate primarily from the Mn t2g orbitals and are in good agreement with neutron diffraction measurements. The ground state is found to be antiferromagnetically ordered along  planes in agreement with experiment. By mapping the energy differences between various spin configurations to a Heisenberg model we find that the dominant interactions in MnN are a second nearest neighbor ferromagnetic interaction due to double exchange via nitrogen and a nearest neighbor antiferromagnetic direct exchange interaction about 4 times smaller than the second nearest neighbor interaction. In Mn3N2, there are fewer second nearest interactions because of the N vacancies but the nearest neighbor interactions are increased by a factor two due to the structural relaxations which brings the Mn closer together. Longer range interactions were considered but do not essentially improve the model. In the mean field approximation, this model predicts a lower Neel temperature for Mn3N2 than in MnN in contradiction with the experiments. This cannot be due to effects beyond mean field. We suggest that the phase transition observed at higher temperature in Mn3N2 may not be magnetic in origin but may be a vacancy order-disorder transition. The magnetic phase transition may as yet be unobserved because of the second order nature of the transition.