A method for maintaining a routing table, the method comprising the following steps: when the Hash value of a to-be-added host route collides with the hash value of a route in a host routing table, then adding the to-be-added host route into a Ternary Content Addressable Memory, TCAM; storing host routes and subnet routes in different TCAM resource sections; characterized in that the step of adding the to-be-added host route into the TCAM specifically comprises: judging whether idle resources exist in the TCAM, and if the judgment result is yes, further judging whether idle resources exist among all TCAM resources occupies by the host routes, or between the last TCAM resource occupied by the host route and the first TCAM resource occupied by the subnet route; and if the idle resources exist among all TCAM resources occupies by the host routes, or between the last TCAM resources occupies by the host route and the first TCAM resources occupies by the subnet route, then adding the to-be-added host route into the first idle resource of the TCAM; or if the idle resources do not exist among all TCAM resources occupies by the host routes, or between the last TCAM resources occupies by the host route and the first TCAM resources occupies by the subnet route, then storing the subnet routes into the TCAM resources of the TCAM starting from the last TCAM resource of the TCAM sequentially, and adding the to-be-added host route into the first idle resource of the TCAM after storing the subnet routes. when the Hash value of a to-be-added host route collides with the hash value of a route in a host routing table, then adding the to-be-added host route into a Ternary Content Addressable Memory, TCAM; storing host routes and subnet routes in different TCAM resource sections; characterized in that the step of adding the to-be-added host route into the TCAM specifically comprises: judging whether idle resources exist in the TCAM, and if the judgment result is yes, further judging whether idle resources exist among all TCAM resources occupies by the host routes, or between the last TCAM resource occupied by the host route and the first TCAM resource occupied by the subnet route; and if the idle resources exist among all TCAM resources occupies by the host routes, or between the last TCAM resources occupies by the host route and the first TCAM resources occupies by the subnet route, then adding the to-be-added host route into the first idle resource of the TCAM; or if the idle resources do not exist among all TCAM resources occupies by the host routes, or between the last TCAM resources occupies by the host route and the first TCAM resources occupies by the subnet route, then storing the subnet routes into the TCAM resources of the TCAM starting from the last TCAM resource of the TCAM sequentially, and adding the to-be-added host route into the first idle resource of the TCAM after storing the subnet routes. judging whether idle resources exist in the TCAM, and if the judgment result is yes, further judging whether idle resources exist among all TCAM resources occupies by the host routes, or between the last TCAM resource occupied by the host route and the first TCAM resource occupied by the subnet route; and if the idle resources exist among all TCAM resources occupies by the host routes, or between the last TCAM resources occupies by the host route and the first TCAM resources occupies by the subnet route, then adding the to-be-added host route into the first idle resource of the TCAM; or if the idle resources do not exist among all TCAM resources occupies by the host routes, or between the last TCAM resources occupies by the host route and the first TCAM resources occupies by the subnet route, then storing the subnet routes into the TCAM resources of the TCAM starting from the last TCAM resource of the TCAM sequentially, and adding the to-be-added host route into the first idle resource of the TCAM after storing the subnet routes. <EOS>