IP addresses are used to route packets to the correct network and device. There are two main versions: IPv4 uses 32-bit addresses divided into four groups, while IPv6 uses 128-bit hexadecimal addresses. IP addresses are classified and divided into network and host portions based on their class. Private IP ranges are used internally while public IPs are used for internet communication. Subnet masks identify the network and host portions of an IP.