The netmask, or network mask, is a 32-bit number that indicates the range of IP addresses belonging to a single IP network, subnet, or supernet. The primary function of the netmask is to divide an IP address into two parts: the network address and the host address. This allows for determining whether two IP addresses belong to the same network.
Representation
The netmask is often displayed as a hexadecimal number. For example, the network mask for a Class C IP network is displayed as 0xffffff00. However, it is common to find the netmask represented in dotted-decimal notation, where each octet is separated by a dot. Using the previous example, the netmask 0xffffff00 is displayed as 255.255.255.0.
Class C
Class C networks have a default netmask of 255.255.255.0. This means that the first 24 bits (the first three octets) of the IP address identify the network, while the last 8 bits (the last octet) identify the individual hosts within that network. In other words, a Class C network can support up to 256 IP addresses, of which 254 are usable for hosts (excluding the network address and the broadcast address).
Usage
Netmasks are fundamental to the operation of IP networks. They are used by routers and network devices to determine whether an IP packet should be sent within the local network or if it should be forwarded to another network. For example, if a device with the IP address 192.168.1.10 and the netmask 255.255.255.0 needs to communicate with another device with the IP address 192.168.1.20, the router recognizes that both addresses belong to the same network and sends the packet directly. If, however, the destination address were 192.168.2.10, the router would forward the packet to a different network.
Subnetting and Supernetting
In addition to dividing an IP network into smaller subnets (subnetting), netmasks can also be used to combine multiple IP networks into a larger network (supernetting). This is useful for managing and simplifying routing tables in complex networks.
Subnetting Example
Consider a network with the address 192.168.1.0/24 (where /24 indicates a 24-bit netmask). We can divide this network into four smaller subnets using a netmask of 255.255.255.192 (/26):
192.168.1.0/26: Addresses from192.168.1.0to192.168.1.63192.168.1.64/26: Addresses from192.168.1.64to192.168.1.127192.168.1.128/26: Addresses from192.168.1.128to192.168.1.191192.168.1.192/26: Addresses from192.168.1.192to192.168.1.255
Supernetting Example
If we have two Class C networks, 192.168.1.0/24 and 192.168.2.0/24, we can combine them into a single network using a netmask of 255.255.254.0 (/23). This gives us a larger network with addresses ranging from 192.168.1.0 to 192.168.2.255.
In summary, the netmask is an essential tool for the subdivision and aggregation of IP addresses within a network, facilitating the management and configuration of computer networks.
