What is a Subnet
Subnetworks or Subnets are used by local area networks that are often connected to the internet and are used to divide a larger network into smaller subnets. How and why a subnet is implemented is based on the preference of the networking administrator. All devices that are connected to the same subnet can communicate with each other directly over the subnet, however devices outside of the subnet (i.e. not connected to the subnet) have to communicate via a router. By utilising a subnet, not only does this reduce overall network traffic, but it also adds an extra layer of security to all devices and data on the subnet as inbound data must always be transmitted through a router, which has firewall capabilities. In addition, local network traffic on the subnet is contained within the subnet and never reaches the broader network or the internet, minimising its exposure to viruses or corruption.
In order for a device to be connected to a subnet, its IP address must match the subnet's IP address for the length of the subnet mask. A subnet mask is a numerical value within an IP address that defines a broader range of IP addresses that are connected to a particular part or section of a network. For example, if the subnet's mask is 192.168.255.X then any device that wishes to connect to it must also have 192.168.255 as the first 3 group values of its IP address. The subnet mask can never include the 4th value in any IP address, this is reserved for the devices that will ultimately want to be connected to the device. It should also be noted that in IPv4, the first and last address in any subnet cannot be assigned to any individual host, i.e. a subnet of all 1s or all 0s is not allowed. The zero address, 0.0.0.0, is the local network, it is used to specify a network without specifying a host. The 255.255.255.255 address is known as the [broadcast address](https://en.wikipedia.org/wiki/Broadcast_address), it is used to send a message to all hosts on a network. IPv6 does not define broadcast addresses. For example, if the subnet's mask is 192.168.255.X then any device that wishes to connect to it must also have 192.168.255 as the first 3 group values of its IP address. The subnet mask can never include the 4th value in any IP address, this is reserved for the devices that will ultimately want to be connected to the device.
For example: I want to connect 3 computers to a subnet. The subnet mask is 192.168.255.X (Where X is reserved for the device and this is a subnet of /24). I have connected 2 of the PCs to the subnet as 192.168.255.1 and 192.168.255.2. The 3rd PC has the IP address 192.168.200.3, this won't connect to the subnet as the subnet mask on the device does not match that of the subnet. Changing 200 to 255 would allow the 3rd PC to connect as well.
There are a range of different subnet that use different notations, see the table below: