Botnets, especially peer-to-peer (P2P) botnets have become the root because of many Internet attacks recently. To effectively suppress P2P botnets, quarantine and virtual patching strategy are proposed and two dynamical models (SIIQR model and SIIQPR model) are given based on the SIIR model. The two models can examine the impact of different containment strategies on the growth of the P2P botnets. In addition, the stability of equilibrium is investigated and the basic reproduction number is obtained, which governs whether or not P2P botnets are extinct. The virtual patching strategy and quarantine strategy can effectively contain the propagation of the P2P botnets. Numerical and simulation results show the effectiveness of our models, larger infected rate, and larger deploying rate of virtual patching can control the number of infected hosts more effectively.