How to find IP addresses and subnet number in a few seconds
Networking February 20th, 2007When you know IP address and mask number, you sometimes want to know subnet number, subnet broadcast address and range of valid IP addresses. In common ways, you can find these by convert the IP address with mask number to binary and perform boolean AND but that takes too much time. So let see how to find these answers in a short time.
Before I start, let see the general table which will used to describe IP address. In each column will be the IP address that separate by octet, dot-notation (x.x.x.x). In each row is the IP address.
Generic Subnet Table
| Octet | 1 | 2 | 3 | 4 |
|---|---|---|---|---|
| Address | ||||
| Subnet number | ||||
| First Address | ||||
| Broadcast Address | ||||
| Last Address |
Let’s start
I divide into 2 categories which depend on subnet mask:
- Do Maths with easy masks
For the masks that contain only 255s and 0s. There are three masks which are 255.0.0.0, 255.255.0.0 and 255.255.255.0.
I guess many people know this already, but l will explain a little bit to revise for someone.- Find the subnet number
- Copy first octet (mask 255.0.0.0), first two octets (mask 255.255.0.0) or first three octets (mask 255.255.255.0) from IP address
- Put 0s in the remaining octets
- Find the broadcast the address
- Copy first octet (mask 255.0.0.0), first two octets (mask 255.255.0.0) or first three octets (mask 255.255.255.0) from IP address. This is the same in ‘Find the subnet number’, step 1
- Put 255s in the remaining octets
- Find range of valid IP addresses
- To find the first valid IP address, copy the subnet number and add 1 to the fourth octet
- To find the last valid IP address, copy the broadcast address and subtract 1 to the fourth octet
- Example
- Mask 255.0.0.0
Octet 1 2 3 4 Address 10 110 140 1 Subnet number 10 0 0 0 First Address 10 0 0 1 Broadcast Address 10 255 255 255 Last Address 10 255 255 254 - Mask 255.255.0.0
Octet 1 2 3 4 Address 10 110 140 1 Subnet number 10 110 0 0 First Address 10 110 0 1 Broadcast Address 10 110 255 255 Last Address 10 110 255 254 - Mask 255.255.255.0
Octet 1 2 3 4 Address 10 110 140 1 Subnet number 10 110 140 0 First Address 10 110 140 1 Broadcast Address 10 110 140 255 Last Address 10 110 140 254
- Mask 255.0.0.0
- Find the subnet number
- Do Maths with difficult masks
In this case, most people find it’s difficult to calculate and some has to do by binary math which is time consuming. Let see the way to figure out in few seconds.- Find the subnet number
- I will define the column that contain the difficult number(not 255s and 0s) as the interesting column. For any octets fully to the left of the interesting column, copy value(s) from the original IP Address into all addresses(subnet number, first-last address and broadcast address).
Octet 1 2 3 4 Address 130 4 102 1 Mask 255 255 252 0 Subnet number 130 4 First Address 130 4 Broadcast Address 130 4 Last Address 130 4 - For any octets fully to the right of the interesting column, put 0s in the subnet number.
Octet 1 2 3 4 Address 130 4 102 1 Mask 255 255 252 0 Subnet number 130 4 0 First Address 130 4 Broadcast Address 130 4 Last Address 130 4 - Now the tricky part, find a ‘magic number’ which is 256 minus mask’s interesting octet. In this example, it is 256 – 252 = 4.
- Find the multiple of the magic number that is closest to, but not greater than the the interesting octet of original IP address. For this case, it is 100 (4*25) which also not greater than 102.
- Put the result from previous step in subnet number of the interesting column.
Octet 1 2 3 4 Address 130 4 102 1 Mask 255 255 252 0 Subnet number 130 4 100 0 First Address 130 4 Broadcast Address 130 4 Last Address 130 4
- I will define the column that contain the difficult number(not 255s and 0s) as the interesting column. For any octets fully to the left of the interesting column, copy value(s) from the original IP Address into all addresses(subnet number, first-last address and broadcast address).
- Find the broadcast address
- For any octets fully to the right of the interesting column, put 255s in the broadcast address. The left part should be filled already in Find subnet number, the upper.
- Again, use the magic number. By adding the magic number to the interesting octet of subnet number and subtract 1. In this example, the magic number is 256 – 252 = 4, 100 + 4 – 1 = 103.
- Put the result from previous step in broadcast number of the interesting column.
Octet 1 2 3 4 Address 130 4 102 1 Mask 255 255 252 0 Subnet number 130 4 100 0 First Address 130 4 Broadcast Address 130 4 103 255 Last Address 130 4
- Find range of valid IP addresses
The way used to find the first and last IP addresses are the same in easy mask.- To find the first valid IP address, copy the subnet number and add 1 to the fourth octet
- To find the last valid IP address, copy the broadcast address and subtract 1 to the fourth octet
Octet 1 2 3 4 Address 130 4 102 1 Mask 255 255 252 0 Subnet number 130 4 100 0 First Address 130 4 100 1 Broadcast Address 130 4 103 255 Last Address 130 4 103 254
- Find the subnet number
Reference: CCNA Self-Study, CCNA ICND, Chapter 4: IP Addressing and Subnetting
Related post
No related posts.




February 22nd, 2007 at 5:41 am
For the class A (255.0.0.0) example, shouldn’t the first usable IP be 10.0.0.1? Also, on the first paragraph (Do Maths with easy masks), shouldn’t the last mask be 255.255.255.0?
February 22nd, 2007 at 7:31 am
Yes, you’re right. It’s my fault.
I have fixed them already. Thanks.
March 7th, 2007 at 12:39 am
Oh nice! Very pretty page!
July 30th, 2007 at 2:46 pm
Your work is magnificent.It has been of great help to me.Try to develop simmilar type of page on other topics of networking too.
BEST OF LUCK.
November 5th, 2008 at 9:19 am
I have a new practical knowledge.
Thanks
December 24th, 2008 at 6:46 am
How do you do the samething for 192.168.200.23 /28
Thanks
December 24th, 2008 at 9:43 am
Hi, xzyan
Have you tried to find it by yourself? It’s quite easy and fast.
Mask Bits: 28 => 255.255.255.240
So we’re interested in the last column.
Magic number: 256-240 = 16
So the subnet number = 192.168.200.16
(Multiple of magic number: 16,32,64,..)
The broadcast address = 16 + 16 – 1 => 192.168.200.31
First address = 16 + 1 => 192.168.200.17
Last address = 31 – 1 => 192.168.200.30
January 6th, 2009 at 11:54 pm
Need your help. Tried this out and running into a problem. Can you help me figure out a valid broadcast address for 10.0.0.0/13 ? maybe if i see your work it will show the error in mine. thanks
January 7th, 2009 at 9:10 am
Hi, Matt
Let’s see if I can do it.
Mask Bits: 13 => 255.248.0.0
So the second column is what I’m interested.
Magic Number: 256-248 = 8
So the subnet number = 10.0.0.0
Because there is no multiplier of 8 which greater than 0, so the second column is 0.
The broadcast address = 0(the second column number) + 8(the magic number) – 1 = 7 => 10.7.255.255
First address = 10.0.0.1 (increment subnet number)
Last address = 10.7.255.254 (decrement the broadcast address)
January 8th, 2009 at 1:32 am
cool I was right! thanks a lot for your help, I think I finally understand this.
February 14th, 2009 at 12:59 am
How do this problem 172.16.2.0/25
February 14th, 2009 at 9:40 pm
Hi, Preet
Why don’t you try by yourself first? I think it’s not too difficult. There are few examples in comments.
March 28th, 2009 at 3:18 pm
Just wanna say thank you.
U make my life much easier!
May 19th, 2009 at 5:22 pm
sory i want to learn more about subnet number and host number
June 5th, 2009 at 4:11 am
Hi Preet if i am not wrong then
Mask Bits: 25 => 255.255.255.128
So the fourth column is what we are interested.
Magic Number: 256-128 = 128
So the subnet number = 172.16.2.128
Because the multiplier of 128,256 and so on
The broadcast address = 128(the fourth column number) + 128(the magic number) – 1 = 255 => 172.16.2.255
First address = 172.16.2.129 (increment subnet number)
Last address = 172.16.2.254 (decrement the broadcast address)
August 14th, 2009 at 10:29 pm
I am confused. What happens when the magic number is larger than the subnet number’s last octet? For example:
190.4.80.80/25 (255.255.255.128)
magic number here is 128 (greater than 80)
Subnet# is 190.4.80.0. How does the booklet get a broadcast address of 190.4.80.127????
August 15th, 2009 at 9:10 am
Hi, Luis
The magic number is 128 and the subnet number is 190.4.80.0. Therefore, the broadcast address is 190.4.80.127 where 127 is came from adding the magic number to the interesting octet of subnet number and subtract 1 (0 + 128 – 1 = 127).
August 19th, 2009 at 1:56 am
My question is why is the number 25 used when trying to find the mutiple?
August 19th, 2009 at 8:07 am
Hi, Kevin
Did you means the number 25 on Do Maths with difficult masks -> Find the subnet number -> step 4? If yes, the number is multiple of the magic number and must be closest to and not be greater than the the interesting octet of original IP address.
On the example, the magic number is 4 and the interesting octet is 102. If you try to find the number, (4*1=4, 4*2=8, 4*3=12, …., 4*25=100, 4*26=104, you will see that 25 is the number that is closest to and less than the interesting octet (26 is greater than the interesting octet).
December 18th, 2009 at 1:09 am
what is subnet number and the host number for the ip 108.77.51.70 and the subnet mask 255.255.128.0..
plz explain..?
thanks..
January 6th, 2010 at 11:11 am
Hi, Ram
I believe that I have shown many examples which you can apply to yours.
February 1st, 2010 at 12:15 am
umm.. how well u find the subnet and host per subnet of the ff:
192.162.54.33 if u dont mind…
i solved this one:
255.255.255.224
11100000
subnet: 2cube – 2 = 4
host/subnet: 2(raised to five) – 2 = 30host/subnet
please xplain?. i really need it for tom.. THANK YOUUUU :>
February 1st, 2010 at 12:50 am
sorry.. i asked the wrong question..
what i wanna find out is how you get the binary numbers?..
in order to find your subnet and host/subnet…
e.g.: 255.255.255.224
thanks
where did 11100000 came from??
February 3rd, 2010 at 11:24 am
Hi, Hannah
So the final question is that you want to know how to convert from 224 in decimal to 11100000 in binary?
You can find a binary number using short division by two with remainder. You keep do short division, write the remainder (0 or 1) at the right side of each division. Finally, the answer is read from the bottom to top on the remainder column.
See the example, 224
2)224 0
2)112 0
2)056 0
2)028 0
2)014 0
2)007 1
2)003 1
2)001 1
2)000 0
The answer is 011100000 (the remainder from bottom to top).
February 12th, 2010 at 10:06 am
hi all,
can somebody explain me if 10.0.0.0/13 then how we resolve the mask of this would be Mask Bits: 13 => 255.248.0.0
please explain me
February 16th, 2010 at 10:06 am
Hi, Yogesh Kapil
Here is how to convert Mask Bits (CIDR) 13 to subnet mask,
February 18th, 2010 at 9:33 am
How do you answer a question like:
How many subnets and hosts can be found with 10.0.0.0/20?
I understand from your teaching how to find the ranges but to get the number of subnets and hosts it seems i have to write it all out.
thank you
February 19th, 2010 at 2:59 am
I may have figured it out.
8 bits for the class A
12 subnet bits and 12 host bits
2^s, and 2^h-2.
4096 subnets and 4094 hosts
?? Does that look right?
thanks
Scott
February 23rd, 2010 at 10:11 am
Hi, Scott
Yes, that’s right.
March 2nd, 2010 at 11:24 pm
Very nice post, thank you so much for the simple method to determine IP ranges. I’m about to take Microsoft 70-291 and then the Cisco CCNA test and this helps out a ton!
March 9th, 2010 at 4:22 am
I tried your formula with 190.165.106.119/23 but was way off. Please work it out for me so I can see where I went wrong.
March 12th, 2010 at 9:15 am
Hi, Larry
Mask bits: 23 => 255.255.254.0
So we’re interested in the third column.
Magic number: 256-254 = 2
So the subnet number = 190.165.106.0
(Multiple of magic number: 2,4,6,…,104,106)
The broadcast address = 106 + 2 – 1 => 190.165.107.255
First address = 190.165.106.1
Last address = 190.165.107.254
March 15th, 2010 at 3:47 pm
how to get the subnet of 100.20.0.0/21
March 17th, 2010 at 4:46 pm
first of all we work out 21 bits
21 —> 224 in decimal
255.255.224.255
so we are interested in the third coloumn
the magic number : 256 – 224 = 32
so the subnet : 100.20.32.0
March 20th, 2010 at 6:46 pm
16.0.0.0/8. An organization is granted the block the administrator wants to create 500 fixed-length subnets.
a) Find the subnet mask.
b) Find the number of address in each subnet.
c) Find the first and last addresses in subnet 1.
d) Find the first and last addresses in subnet 500.
How to Find the first and last addresses in subnet 500.
?
Any Solution on it?please provide me..Thank in advance…
March 22nd, 2010 at 11:55 pm
Ahmed – in answering Kulas’s question about finding the subnet of 100.20.0.0/21, shouldn’t the mask be 255.255.248.0? I can get the broadcast of 100.20.7.255, last of 100.20.7.254, but I can’t get the 1st?
March 28th, 2010 at 6:28 pm
Hi Everyone:
I am stuck with this question here… I am new to this so having a lot of trouble in finding out the way around. My question is, given an ip address 17.212.89.111 and that each subnet has been designed to accommodate 700 hosts:
a. What is the subnet mask in dotted decimal and slash notation?
b. How many usable hosts are there per subnet?
c. What is the network and the broadcast address of the subnet the specified host belongs to?
March 28th, 2010 at 9:31 pm
Ravi,
Hope I got this right.
Question B: The power of 2 shows at position 10 you have the number 1024. (2^h-2=hosts) or (2^10-2=1022) The next lowest is 512 which is lower than your required 700.
Question A: So 10 bits for the host part. Look at this,
Class A gives you 8 bits for the network
Using 10 bits for the host leaves a remaining 14 bits for the subnets (subnets available= 2^s=subnets or 2^14=16384)
nnnnnnnn.ssssssss.sssssshh.hhhhhhhh
For the slash notation just count from the left to right till you get to the hosts = 22 or 8+8+6=22 (255.255.252.0)
17.212.89.11/22 or 17.212.89.11 255.255.252.0
Question c: Now armed with the above solutions you can do the math Linglom shows us to get
subnet – 17.212.88.0
broadcast – 17.212.91.255
I checked it with the subnet calculator and it shows true.
Hope it helps,
Scott
March 29th, 2010 at 1:42 pm
Hi Scott:
Thank you for your reply, your response is highly appreciated. However if you could show me a detailed calculation it would be greatly appreciated as I am new to this so I am not able to understand what you have shown in the answers above. For example, why we having a 10 bit host etc… if that could be shown here in this space then it would make my life much easy…
I look forward to your explanation…
Thank you so very much for your response.
Regards,
Ravi
March 29th, 2010 at 6:57 pm
Ravi,
to get the 10 bit host, use the powers of 2 like this:
1×2=2
2×2=4
2×4=8
2×8=16
2×16=32
2×32=64
2×64=128
2×128=256
2×256=512
2×512=1024 and so on…. (I referred to this as position 10 for my own convenience)
Now you have your 10 bit position for the hosts.
How else may I help?
Scott
(Linglom, please check these things. Don’t let me show Ravi wrong. I am just answering his questions because I need the challenge.)
March 30th, 2010 at 12:21 am
Hi Scott:
Thanks again for your response, however here are my few questions again:
1. As per your calculations is it 1024 valid IP’s available?
2. Can you show me a detailed calculation of my last question that is how to find the subnet and broadcast IP addresses?
I know I am asking too much here but I am really getting into it… and trying to figure out with some easy calculations/maths to figure out the answers to my questions… Hope you would understand… All I need is a step by step calculation of my aforesaid questions as I am new to networking and IP addressing, it will be a pleasure to know the in-depth way of calculating the IP addresses etc… I know Linglom has shown it with an easy math but since I am new to all this I am not able to get it…
Your response would be highly appreciated.
Regards,
Ravi
March 30th, 2010 at 9:58 pm
Hey Scott:
Help Please…
Regards,
Ravi
March 30th, 2010 at 10:38 pm
Ravi,
hang in there friend. I am working right now.
force yourself to go line by line, step by step with what Linglom has shown us in the mean time. I will get time for this later. He has given us some good stuff.
Scott
May 9th, 2010 at 11:26 am
Hi Frndz,
Any one pls help me to find the wild card mask range for the IP’s 172.21.188.120 to 172.21.188.140…….
May 15th, 2010 at 3:46 pm
Dear, I have a IP 12.200.50.0/17 where the magic number 128 is grather then 50 . so what is the solution for finding subnet number > please reply me
fasolution@gmail.com
May 16th, 2010 at 4:35 pm
Hey Amit:
After researching on these topics for a long time now, I can now calculate these things in a snap… In your case the subnet with ip address 12.200.50.0/17 would be 255.255.128.0 since 12.200.50.0/17 means you have 8+8+1 of subnet ID and this being a class A ip address you have the rest of the part as host bits. Please revert if you need any further information.
June 12th, 2010 at 7:19 am
hey guys ,
this is my question .
host ip 172.30.1.33 Subnet mask 255.255.255.192(/26)
1. consider octet where subnet masks occur _____
2. subnet address for given ip address ______
3. broadcast address for this subnet ______
can u pls help me with these questions .:)
pls explain every step how u did it as i am new to this
cheers
June 29th, 2010 at 2:42 pm
How did you obtain the mask 255.255.252 for the ip address 130.4.102.1?
August 7th, 2010 at 2:31 am
how to find subnet number and host number
August 23rd, 2010 at 3:06 am
@monu
No. of subnet = 2^n (n = no. of borrowed 1s)
No. of host = 2^m – 2 (m = no. of remaining 0s)
Please note that IOS which is older than 12.x you will have to use “ip subnet zero” command to start subnet from “0″ otherwise no. of subnet will be 2^n – 2. “ip subnet zero” command is enable by default on all IOS after 12.x.