1. A router, comprising: a communication interface configured to receive a data packet; a TCAM module including: a rule memory module configured to store a plurality of rules in association with corresponding port ranges, the rule memory module having a plurality of unused bits; an assignment module configured to encode a plurality of most commonly occurring ranges so as to occupy one or more of the plurality of unused bits, the assignment module separating the plurality of unused bits into a first virtual partition designated for a non-overlapping range from among the plurality of most commonly occurring ranges and a second virtual partition designated for an overlapping range from among the plurality of most commonly occurring ranges; a processor module configured to determine at least one rule applicable to the data packet; and a priority module configured to select a final rule to be applied to the data packet; and a rule execution module configured to execute the selected rule on the data packet.