An IP address look-up device is for looking up an IP address of an IP
packet in order to forward the IP packet. The device includes a ternary
CAM including pairs of data string and mask string, with the data string
having a prefix of an IP address and the mask string representing a
length of the prefix, and having routing entries stored in physical
segments, respectively, without regard to order of prefix length, the
ternary CAM functioning to compare a search key as a destination address
of the IP packet to be forwarded, with the routing entries, set a match
line of a matching routing entry, and output a mask string of the
matching routing entry; and a priority encoder functioning to compare
prefix lengths of mask strings outputted in correspondence to set match
lines when at least one match line is set in the ternary CAM, determine,
as an LPM entry, a routing entry corresponding to a longest mask string,
and output a physical address of the LPM entry on the basis of a match
line of the LPM entry.