A method for testing a network device, executed by a network device testing apparatus, the method comprising: creating a testing packet library based on characteristic information and service configuration of a network device; acquiring characteristic information and service configuration of a to-be-tested network device; matching a testing packet in the testing packet library according to the acquired characteristic information and service configuration of the to-be-tested network device, and testing the to-be-tested network device by using the matched testing packet, wherein the characteristic information of the network device comprises a type and a model of the network device, wherein the method further comprises: creating a general testing packet library and a random testing packet library corresponding to a type of the network device; testing the to-be-tested network device by using a packet in the general testing packet library and a packet in the random testing packet library, and judging whether there is a loophole and a backdoor in the to-be-tested network device according to a response of the to-be-tested network device, wherein the method further comprises: creating a response action library corresponding to the testing packet library based on the characteristic information and the service configuration of the network device; accordingly, the judging comprises: comparing a response of the to-be-tested network device with the response action library when testing the to-be-tested network device, so as to judge whether an action of the tested network device is legal. creating a testing packet library based on characteristic information and service configuration of a network device; acquiring characteristic information and service configuration of a to-be-tested network device; matching a testing packet in the testing packet library according to the acquired characteristic information and service configuration of the to-be-tested network device, and testing the to-be-tested network device by using the matched testing packet, wherein the characteristic information of the network device comprises a type and a model of the network device, wherein the method further comprises: creating a general testing packet library and a random testing packet library corresponding to a type of the network device; testing the to-be-tested network device by using a packet in the general testing packet library and a packet in the random testing packet library, and judging whether there is a loophole and a backdoor in the to-be-tested network device according to a response of the to-be-tested network device, wherein the method further comprises: creating a response action library corresponding to the testing packet library based on the characteristic information and the service configuration of the network device; accordingly, the judging comprises: comparing a response of the to-be-tested network device with the response action library when testing the to-be-tested network device, so as to judge whether an action of the tested network device is legal. creating a general testing packet library and a random testing packet library corresponding to a type of the network device; testing the to-be-tested network device by using a packet in the general testing packet library and a packet in the random testing packet library, and judging whether there is a loophole and a backdoor in the to-be-tested network device according to a response of the to-be-tested network device, wherein the method further comprises: creating a response action library corresponding to the testing packet library based on the characteristic information and the service configuration of the network device; accordingly, the judging comprises: comparing a response of the to-be-tested network device with the response action library when testing the to-be-tested network device, so as to judge whether an action of the tested network device is legal.