Traceroute is a CLI tool that uses ICMP messages to identify all routers in the path between a source and destination by incrementing the Time to Live parameter. It sends packets with increasing TTLs, causing each router to generate a Time Exceeded message that reveals its address. This allows traceroute to troubleshoot network problems by identifying where issues may be occurring along the path.