In yesterday’s article I covered the basics of Ethernet cabling, hubs and switches.
In today’s article I’ll cover the essential Ethernet basics of IP Addressing, including Host IDs, Subnet Masks, Default Gateways, and Reserved Addresses.
Ethernet IPv4 Address and Subnet Mask Basics:
Those familiar with bits and bytes will have an advantage in this discussion as the standard IPv4 Address and Subnet Mask are each made up of four bytes (also known as octets.)
And while it’s true the networking industry is moving to IPv6 (represented by Eight groups of Four hexadecimal digits, aka Eight 16 bit groups) IPv4 is still the most commonly used scheme for home, office, and controls networks.
The first thing to understand about IPv4 Addresses is that each address contains two pieces of information, which are identified using a Subnet Mask.
In simple terms, the high bits represent the “Subnet” aka (“NetID” or network number) and the remaining low bits represent the “Host ID” (aka “host identifier” or device address.)
To separate the Host ID from the Subnet, we simply perform a “Bitwise AND” between the IP Address and Subnet Mask.
If, for example, you had an IP Address of 192.168.1.5 and Subnet Mask of 255.255.255.0, the result of a “Bitwise AND” of the two reveals the Subnet is 192.168.1, and the Host ID is 5.
How do I know that?
For those unfamiliar with Bit Masking, I like to compare it “Painting Masks” you see road crews use, or the “Stencils” used to make signs.
Each insure only a certain area is painted, which is similar to a Bit Mask which insures only certain bits are passed through while others are filtered out.
For clarity’s sake, let me show how a “Bitwise AND” works by laying out an IP Address and Subnet Mask bit by bit.
Below, you’ll see I’ve converted our above example addresses (IP Address of 192.168.1.5, Subnet Mask of 255.255.255.0) into binary format:
Our IP Address in binary equals: 11000000-10101000-00000001-00000101
Our Subnet Mask in binary equals: 11111111-11111111-11111111-00000000
When we Mask (aka “Bitwise AND”) our IP Address using our Subnet Mask, we only pass through the bits of the IP Address for which the Subnet Mask has a 1:
11000000 10101000 00000001 00000101 = 192.168.001.5 = IP Address
11111111 11111111 11111111 00000000 = 255.255.255.0 = Subnet Mask
——————————————————————–
11000000 10101000 00000001 00000000 = 192.168.001.0 = Subnet
And whatever bits the Subnet Mask does not pass is our Host ID
11000000 10101000 00000001 00000101 = 192.168.001.5 = IP Address
11111111 11111111 11111111 00000000 = 255.255.255.0 = Subnet Mask
——————————————————————–
00000000-00000000-00000000-00000101 = 000.000.000.5 = Host ID
So as seen above, an IP Address of 192.168.1.5 and Subnet Mask of 255.255.255.0 results in a Subnet of 192.168.1, and a Host ID of 5.
For more about Bitwise ANDing see this article HERE.
You’ll probably notice that with a Subnet Mask of 255.255.255.0, also known as a Class C mask, the Subnet takes up the first three bytes (or octets) of the IP Address.
This only leaves one byte for the Host ID, which in turn limits our Host ID to a range of 0 to 255, for a total of 256 available Host IDs (before considering the reserved addresses we’ll cover later.)
Only having 256 Host IDs available for network devices is typically not a problem in a home or small office, but it’s obviously not enough for large facilities or networks.
To address this, we could simply use Subnet Mask of 255.255.0.0 (Class B,) which would leave us potentially more than 65,000 (256×256) Host IDs.
If you’d like to learn more about Subnet Masks and Classes, check out this article HERE.
Why Subnets are Important
Most of us know that each device on our Ethernet network needs a unique IP Addess.
But many don’t understand that Ethernet devices can only communicate with other Ethernet devices on the same Subnet (unless there is a Router bridging Subnets – more on that later.)
Put another way, if you have a Switch and two wired Ethernet devices, for the two devices to communicate they (1) not only need to be wired to the Switch, they (2) also need to logically be on the same Subnet.
For example, let’s say we have two devices wired to a single Switch, and give one an IP Address of 192.168.1.5, and the other an IP Address of 192.168.1.6. And we give both of them a Subnet Mask of 255.255.255.0.
In that example, the two devices would be able to communicate with each other because they both sit on the same 192.168.1 Subnet, as shown below:
IP Address AND Subnet Mask = Subnet
192.168.1.5 AND 255.255.255.0 = 192.168.1
192.168.1.6 AND 255.255.255.0 = 192.168.1
That said, if I changed the second device’s IP Address to 192.168.2.6, it would no longer be able to communicate with the first device (and vice versa) because, even while they are physically connected to the same switch, logically they are now on two different Subnets (192.168.1 vs. 192.168.2) as shown below:
IP Address AND Subnet Mask = Subnet
192.168.1.5 AND 255.255.255.0 = 192.168.1
192.168.2.6 AND 255.255.255.0 = 192.168.2
But, if I then changed both their Subnet Masks to 255.255.0.0, they would be able to communicate again as they would again be on Subnet again, as shown below:
IP Address AND Subnet Mask = Subnet
192.168.1.5 AND 255.255.0.0 = 192.168
192.168.2.6 AND 255.255.0.0 = 192.168
What if my devices are on different Subnets?
If you have devices on different Subnets that need communicate with each other, you’re going to need to add a Router (aka Bridge, Gateway) to your system.
Simply put, a Router “routes” traffic between different Subnets.
But even with a Router correctly setup AND configured to bridge two (or more) networks, there is still one more thing you must do to insure your two devices can communicate with each other!
That is that both devices also need to have the Router’s address set as their Default Gateway address.
This basically tells the device where to send messages to when the message’s address is not on the same Subnet.
Put another way, in the example where I had one device set to 192.168.1.5 / 255.255.255.0, and the other device set to 192.168.2.6 / 255.255.255.0, each Device knew it could not directly message the other because they were logically on different Subnets.
But if I had installed and configured a Router to be connected to each Subnet, and I set each devices Default Gateway as the Router’s local address, then a message sent from one device to the other should be bridged between the two subnets by the Router.
However, without a correctly setup and configured Router to bridge those two Subnets, or without correctly inputting the Router’s address in each device’s “Default Gateway” setting, the two devices would not be able to communicate.
For more about Routers, check out this article HERE.
Reserved Subnets and Host IDs
Now that we’ve covered IP Addresses, Subnet Masks, and Default Gateways, I want to wrap up this article by talking about reserved Subnets and Addresses.
With IPv4 there are three ranges of IP Addresses that have been reserved for private use.
Private Use means that no devices directly connected to the Internet will ever use these address ranges, thus making them available for use in internal private networks (aka Intranets) in homes and businesses.
These ranges are:
10.0.0.0 – 10.255.255.255 (1 Class A network)
172.16.0.0 – 172.31.255.255 (16 Class B networks)
192.168.0.0 – 192.168.255.255 (256 Class C networks)
Some other reserved ranges also include:
169.254.0.0 – 169.254.255.255
This range is used when no server is available to Boot-P or DHCP clients requesting an address.
When no address is received, client devices supporting auto-assigned addresses will randomly pick an IP Address from this range so it can communicate with other devices in the same situation.
127.0.0.0 – 127.255.255.255
This range is reserved for local hosts, aka loopback addresses, and you can typically ping your own computer using an address of 127.0.0.1.
For more information about Private Networks, check out this article HERE.
Reserved Host IDs
As far as reserved Host IDs, the below list can be used as rule of thumb (especially with Class C networks)
x.x.x.0 The network address/represents the network. Should Not be assigned to devices
x.x.x.1 Typically used for the Subnets Router / Bridge / Gateway device
x.x.x.254 Many reserve this address for Routers or Switches which need their own Host ID
x.x.x.255 The network broadcast address. Should Not be assigned to devices
Well, those are what I see as the most important Ethernet Addressing Basics everyone should know.
If you think I should have added something else, or have any questions, comments, or suggestions, please feel free to post the by clicking on the “Click here to post a comment or question” link below.
You can also check out our other Ethernet articles using the links below my signature (coming soon.)
Until next time, Peace ✌️
If you enjoy this episode please give it a Like, and consider Sharing as this is the best way for us to find new guests to come on the show.
Shawn M Tierney
Technology Enthusiast & Content Creator
Eliminate commercials and gain access to my weekly full length hands-on, news, and Q&A sessions by becoming a member at The Automation Blog or on YouTube. You'll also find all of my affordable PLC, HMI, and SCADA courses at TheAutomationSchool.com.
- Anybus Defender Industrial Security Devices (P231) - December 11, 2024
- First Look: New Rockwell Products Shown At Automation Fair 2024 (TME06) - December 6, 2024
- Automation Q & A for December 6, 2024 (QW025) - December 6, 2024
Discover more from The Automation Blog
Subscribe to get the latest posts sent to your email.