After millions of years of evolution, as the representative of the biological world, human beings have adapted well to the earth's environment, including a wide variety of bacteria, chlamydia and viruses. Among them, the immune system plays a big role. But the immune system is also inadequate. For example, when dealing with old viruses, antibodies will gradually decrease or even disappear completely; what's more, in the face of new viruses, the quantity of antibody production is not ideal, maybe even the virus engulfed immune cells. In view of this, this article draws on the human immune system and proposes an immune system-based defence system of robot network security taking advantage of machine learning.