You’re probably wondering how we knew to split the IP address between the 3rd and 4th octet to determine what was the network and what was the host address. You might also be wondering what we do if we need more than 254 devices on our subnet. Well, here’s where subnet masks come in.
A subnet mask defines how much of the IP address belongs to the network address vs the host address. Let’s take a look using a common subnet mask of 255.255.255.0. This is notated the same way as the IP address that we looked at earlier. In binary, it is 11111111.11111111.11111111.00000000. Subnet masks are always a string of ones, switching to a string of zeros. The network address is always the segment of bits that are 1s, and the host address is always the part that is zeros. Let’s look at this next to our IP address in binary (Figure 2):
We can see that the 1s line up with the first three octets which means that this is our network address. The 0s line up with the last octet, which is our host address. What if we need more than 254 IP addresses on a network?
We create a larger subnet and make what’s called a subnet mask.
Let’s allow a few more bits for the network address by changing our subnet mask. This time we’ll go to 255.255.252.0 which, without going too far down the rabbit hole, will allow for 1022 usable IP addresses. In binary, this looks like:
You may have noticed an option on your equipment or computers to enter a “gateway” or “router” address. Let’s say you need devices on one network to communicate with devices on another network. These networks will communicate with each other through a router. The gateway address is the address of the router on the network.
When a device is communicating with something within its subnet, it can reach it directly by its IP address. If it’s trying to get to something outside of its subnet, it knows that it needs to go through the router at the gateway IP address to get there.
A common example is a home network where there’s an internal network that’s routed to the public internet through a router. The devices on the internal network talk to the router at the gateway address in order to access things on the public internet.
Here’s a common AVL example. Say there are two auditoriums with separate control networks, but we want them to communicate with each other so that we can work with all of the wireless microphone receivers at the same time to coordinate frequencies. If each of these is connected to a router, and the router is put in place to allow them to access each other, devices will be able to communicate across networks by going through the gateway address.
This probably sounds like a lot of configuring to do, manually determining IP addresses and assigning them with subnet masks and gateways to each device on a network. Luckily it doesn’t always have to be done manually. When you go to a coffee shop or house and connect a device to WiFi, it usually just works without you having to enter a bunch of IP information, right? This is where the DHCP server comes in.
DHCP runs on a router, a server, or some other piece of equipment depending on a network. In a DHCP configuration, you can set many parameters that you want devices on the network to have including IP addresses, subnet mask, gateway, DNS servers, and a whole pile of other things.
When a device connects to the network, the DHCP server will give it a unique IP address and other assigned information that will allow it to work properly. For most things, using DHCP is great. For anything that needs an IP address that won’t change, which is common in control systems, it can sometimes be a better idea to assign these parameters manually.