Setting up a device on a home network sometimes requires that you manually enter an IP address.
However an IP address alone isn’t sufficient as you will also be require to enter a subnet mask.
So what is a subnet mask and what does it do? and is it important?
Before we look at subnet masks you first need to understand IP addresses.
IP Addresses and IP Address Structure
IPv4 uses 32 bits for addressing. These 32 bits are split into 4 bytes and each byte is separated by a dot(.). So it is of this form:
Where the value of a,b,c or d is between 0-255 decimal. A typical IP address appears like this:
An IP address has two components- A network component, and a node component.
As an Analogy if you think of the address of your house it is of the form
House Number + Street name e.g 22 queen Street.
For computer networks the network number is equivalent to the street name and the house number is the Node Address.
The purpose of the subnet mask is to split the IP address into the two components.
When you combine, using a logical AND, the IP address and the mask you reveal the network address.
So if you have an IP address of 192.168.1.256 and a mask of 255.255.255.0 the network address is 192.168.1 and the host or node is 254.
If we do some more examples:
!P address 10.0.1.1 mask 255.0.0.0
then network is 10 and host is 0.1.1
!P address 10.0.1.1 mask 255.255.0.0
then network is 10.0 and host is 1.1
Importance Of the Subnet Mask
The mask is important as hosts on the same network can talk to each other without a router whereas if they are on a different network then they need a router.
So if we incorrectly configure two hosts which are on the same physical network with the following IP addresses and mask.
Host 1 IP= 192.168.1.1 Mask 255.255.255.0
Host 2 IP= 192.168.1.2 Mask 255.255.0.0
Then host 1 thinks it is on network 192.168.1 and host 2 thinks it is on the network 192.168.
Because these networks are different they will try to use a router to communicate, and will fail.
Home Networks Default Mask
Even if you haven’t quite grasped the subnet mask it is important that you understand that the mask should be the same on all hosts on the same network.
Which on a home network is usually all hosts, as a home network isn’t subdivided into sub networks, and doesn’t use a router internally.
On a home network the only router used is the one that connects the home network to the Internet.
On a home network the mask 255.255.255.0 is almost always used.
Related Tutorials and Resources:
- Basic Networking course
- IP addresses and Classes
- Subnets and subnet Masking explained.
- Configuring Networking on Raspberry Pi