A packet processing method in a distributed device, wherein the distributed device is deployed between a first network and a second network, the distributed device comprises a first offloading unit, a second offloading unit, and at least two processing units, each processing unit in the at least two processing units is coupled to the first offloading unit and the second offloading unit, and the method comprises: receiving, by the first offloading unit, a first packet from the first network, and selecting, based on a data flow identifier of the first packet and a first offloading algorithm, a first processing unit from the at least two processing units, wherein the data flow identifier of the first packet comprises at least a source Internet Protocol IP address, a destination IP address, a source port number, and a destination port number of the first packet; sending, by the first offloading unit, the first packet to the first processing unit; allocating, by the first processing unit, an IP address and a port number to the first packet, wherein the allocated port number satisfies a condition: Based on a data flow identifier of a reverse packet of an address-translated first packet and a second offloading algorithm, a second processing unit selected from the at least two processing units is a same processing unit as the first processing unit, a source port number of the address-translated first packet is the allocated port number, one of a source IP address and a destination IP address of the address-translated first packet is the allocated IP address, and the second offloading algorithm is an algorithm used by the second offloading unit to offload the reverse packet of the address-translated first packet; performing, by the first processing unit, address translation on the first packet, to obtain the address-translated first packet, wherein the address translation comprises replacing the source port number of the first packet with the allocated port number; sending, by the first processing unit, the address-translated first packet to the second offloading unit; and sending, by the second offloading unit, the address-translated first packet to the second network; wherein the second offloading algorithm comprises inputting a source IP address, a destination IP address, a source port number and a protocol number of an input packet and a first port number into a predetermined hash algorithm based on an order indicated by a first manner, performing summation on a result of the hash algorithm and an adjustable value, performing, by a result of the summation, modulo operation on N, and using a processing unit corresponding to a result of the modulo operation as a selected processing unit, wherein the adjustable value is a difference obtained by subtracting the first port number from a destination port number of the input packet, N is a quantity of the processing units comprised in the distributed device, and the at least two processing units respectively correspond to values in a range of 0 to N-1. receiving, by the first offloading unit, a first packet from the first network, and selecting, based on a data flow identifier of the first packet and a first offloading algorithm, a first processing unit from the at least two processing units, wherein the data flow identifier of the first packet comprises at least a source Internet Protocol IP address, a destination IP address, a source port number, and a destination port number of the first packet; sending, by the first offloading unit, the first packet to the first processing unit; allocating, by the first processing unit, an IP address and a port number to the first packet, wherein the allocated port number satisfies a condition: Based on a data flow identifier of a reverse packet of an address-translated first packet and a second offloading algorithm, a second processing unit selected from the at least two processing units is a same processing unit as the first processing unit, a source port number of the address-translated first packet is the allocated port number, one of a source IP address and a destination IP address of the address-translated first packet is the allocated IP address, and the second offloading algorithm is an algorithm used by the second offloading unit to offload the reverse packet of the address-translated first packet; performing, by the first processing unit, address translation on the first packet, to obtain the address-translated first packet, wherein the address translation comprises replacing the source port number of the first packet with the allocated port number; sending, by the first processing unit, the address-translated first packet to the second offloading unit; and sending, by the second offloading unit, the address-translated first packet to the second network; wherein the second offloading algorithm comprises inputting a source IP address, a destination IP address, a source port number and a protocol number of an input packet and a first port number into a predetermined hash algorithm based on an order indicated by a first manner, performing summation on a result of the hash algorithm and an adjustable value, performing, by a result of the summation, modulo operation on N, and using a processing unit corresponding to a result of the modulo operation as a selected processing unit, wherein the adjustable value is a difference obtained by subtracting the first port number from a destination port number of the input packet, N is a quantity of the processing units comprised in the distributed device, and the at least two processing units respectively correspond to values in a range of 0 to N-1.