What is a Netmask, a Subnet and CIDR

What is a Netmask?

An IP netmask is used to split  IP addresses into two parts: the network address and the host address. The network address describes the network that a host belongs to, while the host address identifies a specific host or device on that same network.

Netmasks are 32-bit values that are utilized to mask out the host portion of an IP address, revealing only the network part. They are usually written in the form of a dotted decimal notation, such as e.g 255.255.255.0. Each octet (part separated by a dot) of the netmask is compared to the corresponding octet of the IP address to determine the network and host addresses.

Following are a couple of examples of different netmasks and what they mean for the IP ranges and the network they describe:

  • 255.255.255.0 This netmask is mostly used for small networks, and it corresponds to a subnet of /24. It allows for up to 254 devices on the network, and the IP range would be something like 192.168.1.1 - 192.168.1.254, where the first three octets (192.168.1) identify the network and the last octet (1 - 254) identifies the host.
  • 255.255.0.0: A netmask often used for larger or corporate networks, and it is equivalent to a CIDR (subnet) notation of /16. It allows for up to 65,534 hosts on the network, and the IP range would be something like e.g 10.0.1.1 - 10.0.254.254, where the first two octets (10.0) identify the network and the last two octets (1.1 - 254.254) identify the host.
  • 255.254.0.0 – Corresponds to a CIDR notation of /15. It allows for up to 131,072 hosts on the network. The IP range described by it is enclosed by 10.0.0.1 - 10.1.254.254.
  • 255.255.248.0 That is equal to a Subnet of /21. It describes up to 2,046 hosts on the network. The IP range would be with a first and list IPs 192.168.200.1 - 192.168.207.254 where the first three octets (192.168.200 to 192.168.207). identify the network and the last octet (1 - 254) identifies the host. An example IP in that range would be 192.168.203.1
  • 255.248.0.0 This netmask is also used for large networks and it is equivalent to a Subnet/CIDR value of /13. The netmask 255.248.0.0 allows 524,288 hosts on the network, and the IP Address range allowed is as follows: 192.168.1.1 - 192.175.254.254.

How to find your Netmask?

In MacOS or Linux, you can easily see your current netmask by writing the command “ifconfig” or “route -n” in the terminal

ifconfig

Or

route -n

Linux Terminal route -n output

Doing the same thing in Windows is easily done by right-clicking on the Network Adapter currently in use (in Control Panel), then going to Properties and then Details:

Ethernet Adapter Properties and Details in Windows

What is a Subnet?

A subnet, short for "subnetwork," is a smaller network that is created by dividing a larger network into smaller, easily manageable parts. This is done by using a technique called subnetting, which involves borrowing bits from the host portion of the IP address to create a new network portion. This makes it possible for more efficient use of IP addresses by breaking a large network into smaller sub-networks that can be assigned to different groups of hosts or locations.

What is CIDR?

CIDR, abbreviation for Classless Inter-Domain Routing, is a method for allocating IP addresses and routing Internet Protocol packets. A CIDR value is used to specify the IP address range and the network mask in a compact format. This notation uses a slash (/) followed by a number, called the prefix length, and that is the number of bits that are used for the network segment of the IP address.

For example, an IP address in CIDR notation of 192.168.0.0/24, refers to the network 192.168.0.0 with a netmask of 255.255.255.0 which is a /24 prefix. This notation permits a more organized and structured use of IP addresses by specifying the network section of the IP address directly, rather than relying on the implicit boundaries between IP classes (A, B, C).

CIDR notation is more efficient for IP addressing and routing than the one used before the existence of CIDR - named Classful IP addressing, as it allows for more flexible and structured use of IP addresses, by enabling variable-length subnet masks (VLSMs), supernetting and route summarization.