A subnet mask is a number that defines a range of IP addresses that can be used within a network. It is used to identify the network and host addresses in an IP address, allowing the network to be divided into subnets.