ANDing is the binary process computers use to determine the network address from an IP address and subnet mask. It is a foundational concept in IP subnetting, particularly when custom subnet masks are involved.
ANDing Process
In our last module, when we were talking about IP addresses and classful addressing, we took a look at how to determine network addresses. The network address was that address that represented the whole network, and we had some exercises to determine what the network address was. Well, for a classful system, that's actually really simple to do — that's very easy to do. It gets a little more complicated when you have a custom subnet mask. So let's talk about what that process looks like. It's called ANDing.
Here's a network address that identifies this whole network. As I mentioned, if it was a classful address, it's usually pretty easy to figure out what the network address is for the network. But it becomes a little more difficult when it is a custom subnet mask. Here we have borrowed two bits for these networks, and so we can see that the network addresses are a little different.
But how does your computer figure that out? Well, your computer is assigned some sort of IP address. Let's say it's 192.168.0, and maybe this one right here is .141. So it's .141. That's a piece of information that it has. You've either set it up on it, or a lot of times your networks are set up with DHCP and it receives this IP address from a server. And then it also will receive a subnet mask. So our subnet mask is 255.255.255, and then this is a /26, so we know that's a 192.
So what it does is it does this process called ANDing between these two to come up with the answer of what the network is. In this case right here, it would come up with 192.168.0.128, because that is the network address. But it's got to do some calculation to figure that out.
So let's figure out what that calculation process is. It's called ANDing, and let's go through those steps.
For this scenario right here, I have an IP address. I have that IP address written out in binary. I have the mask right here in binary. We can even write out the mask in decimal — why not — so we're going to write those out.
First of all, we have to come up with a scenario here. Let's just say we're going to borrow 11 bits. So that would be a /19. If I count this out, there's eight ones: 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19. So I'm splitting this right here — that's where we're going to split this off at. And the rest of these for the mask is going to be zero, because these are all host bits. So if I were to figure out the decimal form, this would be 255.255.224.0 is the answer there.
Now, how do we do ANDing? Well, ANDing says that if there is a one in the IP address space and there's a one in the mask, then you will get a one. But if you have a zero and a one, you'll get zero. A one and a zero, you'll get zero. And a zero and zero, you'll get zero. So the only way that you get one is if there's two ones. And you just go bit by bit with this.
So I circle this right here. Is there two ones there? No, there's not. So that's going to be a zero. How about there? No, so zero. How about there? No, zero. How about there? Yes, one. How about there? No, zero. How about there? Yes, one. So you're going to keep doing this. And what you'll end up with, if I just do this real quickly, is 0 0 1 0 0 and then 0 1 1. And the rest of these are going to be zero, because the mask is all zero, so none of the rest of these are going to count here. There's my answer right there.
So now I calculate this. I turn this binary number into a decimal again. So we've got 10 dot. This is 100. That makes sense, because these are all network bits, so it's going to be that and that — it's going to line up. So that makes sense right there. And then this right here, we've got — let's see, that'd be a 64 plus 32, so we're going to get a 96. So 96.0 is going to be, and then /19. That is our network address right there.
So that's how you come up with the ANDing process. If there's a one and a one in both the mask and the IP address, you'll get a one, and in all other scenarios you're going to get a zero. And that's how you figure out — and how your computer figures out — what network it's on, by using the IP address and the mask.
Let's put this into practice. Here are several addresses that I have and the masks for those addresses. Let's figure out what the network address is for each one of those.
So what I can do is I can take this 192.168.0.88 with the mask of 255.255.255.192 and plug it into up here, because I'm going to need to do this with the binary numbers. So I can plug that in. But I don't necessarily need to convert all of this to binary, because I already know that the first three octets are going to be part of the network address. So right from the get-go, I already know that these first three octets in here are going to be 192.168.0. And now I just need to figure out what the last octet is going to be, so I'm only going to fill in the binary numbers for the last octet.
So now I need to convert 88 into a binary number, and 88 into a binary number is going to be a 0 1 0 1 1 0 0. So there I have that. Now I need to take the 192 and convert it into binary. I know that 192 is a 128 plus a 64, and the rest of these are going to be zero. Now I can draw my line right there, and I can do the ANDing process.
This is 0 and 1, so that's going to be a zero. This is a one and one, so that's going to be a one. And the rest of these are just going to be zero, because these are all zeros, so the rest of the network address is all going to be zeros. So now we have the answer right here, which is 64. So there is my answer right there.
Go through the rest of these and figure them out, and then you can check to see how close you came to the answer. There are the answers for this — check your answers to see how close you came.
I wouldn't say that we're going to use this ANDing process a lot when we're doing our subnetting, but it's definitely a concept you should be familiar with. So go ahead and practice this.
TechKnowSurge builds IT and cybersecurity professionals through hands-on, concept-first training built around real understanding — not memorization. Free interactive tools, structured programs, and 25+ years of real-world experience, all in one place.
Explore free tools and programs →