The invention discloses a method for controlling the flow of an IP data stream, which comprises the following steps: step 1, carrying out route and flow classified search on data messages based on a preset key word; step 2, carrying out message header processing and dyeing operation based on the matched table entries of the searching result; and step 3, carrying out follow-up action operations, wherein the matched table entries comprise next hop exit, data type, survival time, committed information rate (CIR), token count in bucket C (Tc), token count in bucket E (Te), committed burst size (CBS) and excess burst size (EBS). Based on the similarity between the precise route search and the flow control and the integral design combining the flow control and the precise route search, the invention can greatly simplify the difficulty in designing the flow control function for the IP data stream on the routing and switching device having the precise route search function, thereby lowing the design and production costs.