A method and an apparatus for building a decision tree for packet classification are provided. According to an example of the present disclosure, a first type decision tree is generated by performing tree building for a classification rule set based on a non-template dimension of the classification rule set; a second type decision tree is generated by performing tree building for each leaf node in the first type decision tree based on a template dimension of the classification rule set; a plurality of leaf nodes that are mutually of the to each other in the first type decision tree are associated with a same second type decision tree. The plurality of leaf nodes that are SPSR to each other indicate that classification rule sets respectively included in the plurality of leaf nodes are SPSR to each other.