A packet transfer controlling apparatus stores, for each of a plurality of comparators, a plurality of associations of a code and a classification to be compared by the comparator when specification of the code is accepted. Also, each selector sets information that belongs to a classification stored in association with the accepted code as information to be selected from the packet. Then, each selector selects the set information when an input of a packet is accepted. Then, each comparator outputs a comparison result indicating whether the information selected by the selector and a comparison value match each other. Next, when the comparison result is output from every comparator, a rule searching unit conducts a search to see which rule the packet is relevant to among a plurality of rules, and then outputs a rule number.