Home   -   Wild Card Masks --nHEX   -     Long Division

 

Subnetting Information

This is for IPV4 only.  IPV6 is a completely different breed of horse. I won't cover it here. IPV4 is still in use and will be for awhile.

I hope this is understandable.


Forget about the long division tables to find a subnet number. Put aside all the so-called short cuts that are easy to get mixed up and often forgotten.  

Stay with BINARY. It is the only sure and safe way to go when working with IP addressing.

 

RULES FOR SUBNETTING
1> Borrow at least 2 bits for networks and leave at least 2 bits for hosts.  
2> Usable subnets = 2n bits borrowed - 2  
3> Usable hosts = 2n bits left -2  
4> Decimal value of last bit borrowed = the increment of the subnet addresses, host addresses and the first usable subnet.

SUBNET MASKS

Default masks         Address range             Max hosts w/0 bits borrowed -2
A - 255.0.0.0                   1 - 126                       16,777,214
B - 255.255.0.0           128 - 191                             65,534
C - 255.255.255.0       192 - 223                                  254

Class A 1 - 126 (First bit = 0) 0xxxxxx
Bits Borrowed Subnet Mask / Max Subnets (-2) Max Hosts (-2)
2 255.192.0.0 10 2 4,194,302
3 255.224.0.0 11 6 2,097,150
4 255.240.0.0 12 14 1,048,574
5 255.248.0.0 13 30 524,286
6 255.252.0.0 14 62 262,142
7 255.254.0.0 15 126 131,070
8 255.255.0.0 16 254 65,534
9 255.255.128.0 17 510 32,766
10 255.255.192.0 18 1,022 16,382
11 255.255.224.0 19 2,046 8,190
12 255.255.240.0 20 4,094 4,094
13 255.255.248.0 21 8,190 2,046
14 255.255.252.0 22 16,382 1,022
15 255.255.254.0 23 32,766 510
16 255.255.255.0 24 65,534 254
17 255.255.255.128 25 131,070 126
18 255.255.255.192 26 262,142 62
19 255.255.255.224 27 524,286 30
20 255.255.255.240 28 1,048,574 14
21 255.255.255.248 29 2,097,150 6
22 255.255.255.252 30 4,194,302 2

Class B 128 - 191 (first 2 bits = 10) 10xxxxxx
Bits Borrowed Subnet Mask / Max Subnets (-2) Max Hosts (-2)
2 255.255.192.0 18 2 16,382
3 255.255.224.0 19 6 8,190
4 255.255.240.0 20 14 4,094
5 255.255.248.0 21 30 2,046
6 255.255.252.0 22 62 1,022
7 255.255.254.0 23 126 510
8 255.255.255.0 24 254 254
9 255.255.255.128 25 510 126
10 255.255.255.192 26 1,022 62
11 255.255.255.224 27 2,046 30
12 255.255.255.240 28 4,094 14
13 255.255.255.248 29 8,190 6
14 255.255.255.252 30 16,382 2

Class C 192- 223 (First 3 bits = 110) 110xxxxx
Bits Borrowed Subnet Mask / Max Subnets (-2) Max Hosts (-2)
2 255.255.255.192 26 2 62
3 255.255.255.224 27 6 30
4 255.255.255.240 28 14 14
5 255.255.255.248 29 30 6
6 255.255.255.252 30 62 2

Finding the number of the subnet a given address is on for Class A (see Long Division for Class B)

What subnet is 122.10.10.156/27 on?

The /27 tells us that 27 bits are used for networks, or 19 bits were borrowed, this means all of the 2nd and 3rd octets and 3 bits of the 4th octet were borrowed for networks. 122 is the assigned network address so this is left alone. Work only with the last 3 octets - 10.10.156

Lay it out in binary as follows -
2nd octet _ _ _ _ _ _ _ _ 3rd octet _ _ _ _ _ _ _ _ and the 4th octet _ _ _ (19 bits borrowed)

Put the numbers 10.10.156 into the 2nd, 3rd and 4th octets like this:
0 0 0 0 1 0 1 0 (=10) . 0 0 0 0 1 0 1 0 (=10) (And as much of the 156 that will fit into the bits that were borrowed from the 4th octet)         1 0 0 (=128)

Discarding the leading zeros in the 2nd octet, we have:
1 0 1 0 0 0 0 0 1 0 1 0 1 0 0
 
1 8 4 2 1 5 2 1 6 3 1 8 4 2 1
6 1 0 0 0 1 5 2 4 2 6        
3 9 9 4 2 2 6 8              
8 2 6 8 4                    
4                            

then add the binary number up           

16384

4096
64
16
4
       =  20564 

122.10.10.156/27 is on the 20564th subnet.

What is the subnet mask of 122.10.10.156/27?
Remember we borrowed 19 bits total, 8 from the 2nd octet, 8 from the 3rd octet and 3 bits from the 4th octet. The decimal value of those LAST 3 bits borrowed is 224 (128+64+32).      _ _ _ | _ _ _ _ _. The subnet mask would be 255.255.255.224. (If we borrowed only 3 bits from the 3rd octet, our subnet mask would be 255.255.224.0. It's still the value of the bits borrowed from the last octet we borrowed from.)

Using Binary math with the subnet mask you will be able to find the wire address of this subnet.

Subnet mask = 255.255.255.224
        Address = 122.10.10.156

We know the wire address starts with 122.10.10 so all we have to add is the 4th octets 

11100000 = 224
10011100 = 156

10000000 = 128

122.10.10.128 is the wire address for 122.10.10.156/27.

A class B address is done the same way. Just use the last 2 octets


Now let's do something a little different but almost the same.

What is the 565th subnet of 122.10.10.156/27?

Again, we know that 19 bits were borrowed, giving us

122. _ _ _ _ _ _ _ _ ._ _ _ _ _ _ _ _ . _ _ _

Starting with the LAST bit borrowed in the 4th octet, plug in 565

122 . _ _ _ _ _ _ _ _ . 01000110 . 101

We now know that the address starts with 122.0
In the 4th octet, add trailing 0's to fill up the octet.

We now have 122 . 0. 01000110.10100000

Convert octets 3 and 4 to decimal and we have the address:

01000110 = 70
10100000 = 160

The address for the 565th subnet of 122.10.10.156/27 is 122.0.70.160

What is the 4050th subnet of 103.15.25.60/20?

How can we determine if an address is a valid Host, Wire or Broadcast address?
Let's take a class C address of 193.10.10.50/28

193.10.10._ _ _ _ | _ _ _ _
We know that 4 bits were borrowed from the 4th octet, so plug the '50' into the whole 4th octet and you have this:

                               <hosts>
193.10.10. 0011 | 0010

There is a '1' in the host portion of the address, so this makes 193.10.10.50 a valid host address.

(You must have at LEAST a single "1" in the host portion to make it a valid host address)

If we have 193.10.10.48/28, we get 193.10.10.0011|0000 so this makes it a Wire address.  
If we have 193.10.10.15/28, we get 193.10.10.0000|1111 so this makes it a Broadcast address.

All 1's in the HOST portion indicates a broadcast address.
All 0's in the HOST portion indicates a wire address.


Now for a class A

120.10.10.50/30

30 bits for networks (22 bits borrowed) and 2 bits for hosts. Plug the '50' in like before.
                                                                                      
We have 120. _ _ _ _ _ _ _ _ . _ _ _ _ _ _ _  _ . _ _ _ _ _ _  | _ _
                 120                                                           0 0 1 1 0 0     1 0 = 50 = valid host address.

What would be the first usable network address for 120.10.10.50/30?

4 is the decimal value of the LAST bit borrowed so our first usable network (wire) address would be 120.0.0.4, our first host address on this wire would be 120.0.0.5, the last host address on this wire would be 120.0.0.6 and the broadcast address for this wire would be 120.0.0.7. The second wire address would be 120.0.0.8 (increment of 4 from the first usable wire address.

Private Addresses

A - 10.0.0.0 (one network)
B - 172.16.0.0 - 172.31.0.0 (16 networks)
C - 192.168.0.0 - 192.168.255.0 (256 networks)

Can we subnet private addresses? Yes. You can do the same thing with private addresses that you can do with public addresses - except go out on the internet with them.