Monday, January 26, 2015

Basic IP Address Calculating

There are four octets in IPv4. Each octet has 8 bits. So, IPv4 is totally 32bits. IPv4 addresses are based on the binary and decimal. Binary is 0 to 1 and decimal is 0 to 9. When all bits are "1"

IPV4   ->   32 bits
                 1st Octet       2nd Octet      3rd Octet      4th Octet
                11111111  .  11111111  .  11111111  .  11111111
                     8 bits            8 bits           8 bits          8 bits
                      255    .         255    .       255      .      255

When all bits are "0"

               00000000  .   00000000   .  00000000   .   00000000
                      0       .           0       .         0         .        0

Sometimes, some bits are "0" and some bits are "1" in the same octet. For example, lets see the ip address 192.168.1.0.

(If we will calculate the Ip addresses, we better write down the following formula.)

  27        26         25        24         23        22      21     20   
128      64       32      16        8        4       2      1
                                                                       

192.168.1.0   

128  64  32  16  8  4  2  1 . 128  64  32  16   8   4   2  1  . 128  64  32  16  8 4  2  1  .  0
 1   1    0    0   0  0  0  0   .  1    0    1    0   1   0   0  0  .   0     0    0    0   0  0  0 1 . 00000000

11000000.10101000. 00000001.00000000


Now, lets try to change the following binary to decimal !

01110000.11000000.00011001.0

0      1     1    1   0   0   0   0  .   1  1  0  0  0  0  0  0  .  0  0  0  1  1  0  0  1 . 00000000
128  64   32  16  8   4   2   1
               
            112                         .             192                 .              25             .       0

112.192.25.0





Subnet Mask 

Subnet Mas is reverse proportional to Ip range. It is mean that the bigger subnet mask, the smaller ip range. 

For example,
192.168.1.0/24  

/24 is mean that 255.255.255.0 .
Network Address - > 192.168.1.0
Subnet Mask      ->   255.255.255.0  = 11111111 . 11111111 . 11111111 . 00000000
IP address range     ->   0 . 0. 0. 11111111 = 255
Usable IP addresses -> 192.168.1. to 254
Broadcast IP address - > 255


Next one,
192.168.1.0/ 26
 
/26 is mean 255.255.255.192 .

 
Network     =   192.168.1.0
Subnet Mask  = 255.255.255.192   =  11111111 . 111111111 . 11111111 . 11 000000
IP address range    =   0  . 0  . 0  .  0  0  1 1 1  1  1  1 =  63
Usable  Ip address = 192.168.1.1 to 62
Broadcast Address = 192.168.1.63

The following table is formula for Ipv4 addresses I've made when I was in Singapore Polytechnic.



Binary      Decimal      Subnet Mask                 Usable Ip Range      Broadcast Address  
 -                     -               255.255.255.0   /24           1 to 254                        255

27               128            255.255.255.128 /25          1 to 126                        127
                     +
26                   64            255.255.255.192 /26          1 to 62                            63   
                    +
25               32            255.255.255.224 / 27          1 to 30                           31
                     +
24                   16           255.255.255.240 / 28           1 to 14                            15  
                    +
23                    8            255.255.255.248 / 29            1 to 6                              7
                   +
22               4             255.255.255.252 /30            1 to 2                              3                            


No comments:

Post a Comment