To solve the distributed task allocation problems of search and rescue missions for multiple unmanned aerial vehicles (UAVs), this paper establishes a dynamic task allocation model under three conditions: 1) when new targets are detected, 2) when UAVs break down and 3) when unexpected threats suddenly occur. A distributed immune multi-agent algorithm (DIMAA) based on an immune multi-agent network framework is then proposed. The technologies employed by the proposed algorithm include a multi-agent system (MAS) with immune memory, neighbourhood clonal selection, neighbourhood suppression, neighbourhood crossover and self-learning operators. The DIMAA algorithm simplifies the decision-making process among agents. The simulation results show that this algorithm not only obtains the global optimum solution, but also reduces the communication load between agents.