Peer to peer network is a new form of distribution system and Gnutella network due to its decentralized nature is a special form of peer to peer network. Because of continuous topological changes and the absence of node’s dependence on a central unit, security creation is hard to access. In this paper a collaborative intrusion detection system is proposed to detect DDoS attacks by the inspiration of artificial immune system. The function of artificial immune system is distributional, collaborative, robust and adaptive. It increases the precision of attack discovery and decreases false positive rate. Therefore in this paper, after detecting attack with adopting some alternatives, the effect of attack is minimized and the function of the system is optimized. To analyze the function of suggested network in training phase, tcpdump and gtk-gnutella tools are used to create the packets of the Gnutella in a new dataset.