| How to find IP addresses and subnet number in a few seconds |
When 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.
| Octet | 1 | 2 | 3 | 4 |
|---|---|---|---|---|
| Address | ||||
| Subnet number | ||||
| First Address | ||||
| Broadcast Address | ||||
| Last Address |
Let get start
I divides into 2 categories which depend on subnet mask:
-
Do Maths with easy masks
- 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 -
Do Maths with difficult masks
- 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 - 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
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.
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.
Reference: CCNA Self-Study, CCNA ICND, Chapter 4: IP Addressing and Subnetting

























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