A network apparatus (10, 30), comprising: a network interface device connected to a network; a storage device storing a block list; a processor coupled to the network interface device and the storage device and configured to: selectively allow a plurality of legal communication ports to serve as service ports for connecting with an external device according to environment information of the network; receive a network packet sent by the external device through the network by using the network interface device, and determine whether identification information of the external device is in the block list; if the identification information is in the block list, block connection of the external device; if the identification information is not in the block list, determine whether a destination port of the network packet is one of the service ports and complies with a connection sequence of the plurality of legal communication ports; if the destination port is one of the service ports and complies with the connection sequence, establish a connection with the external device and provide services; and if the destination port is not one of the service ports or does not comply with the connection sequence, block connection of the external device and add the identification information of the external device to the block list. a network interface device connected to a network; a storage device storing a block list; a processor coupled to the network interface device and the storage device and configured to: selectively allow a plurality of legal communication ports to serve as service ports for connecting with an external device according to environment information of the network; receive a network packet sent by the external device through the network by using the network interface device, and determine whether identification information of the external device is in the block list; if the identification information is in the block list, block connection of the external device; if the identification information is not in the block list, determine whether a destination port of the network packet is one of the service ports and complies with a connection sequence of the plurality of legal communication ports; if the destination port is one of the service ports and complies with the connection sequence, establish a connection with the external device and provide services; and if the destination port is not one of the service ports or does not comply with the connection sequence, block connection of the external device and add the identification information of the external device to the block list. selectively allow a plurality of legal communication ports to serve as service ports for connecting with an external device according to environment information of the network; receive a network packet sent by the external device through the network by using the network interface device, and determine whether identification information of the external device is in the block list; if the identification information is in the block list, block connection of the external device; if the identification information is not in the block list, determine whether a destination port of the network packet is one of the service ports and complies with a connection sequence of the plurality of legal communication ports; if the destination port is one of the service ports and complies with the connection sequence, establish a connection with the external device and provide services; and if the destination port is not one of the service ports or does not comply with the connection sequence, block connection of the external device and add the identification information of the external device to the block list.