IP Address Conversions

All of the information, instructions, and recommendations on this Web site are offered on a strictly "as is" basis. Remember "Murphy's Law." Please take the proper precautions before attempting any of the tips or modifications listed here.

Contents


How to: Convert a Decimal Number to a Base-256 dotted-decimal / dotted-quad
How to: Convert an IPv4 Address to a Decimal Number
Computer Tips index
CS 607: LAN Connectivity

 


[ Top ] [ Home ]

 

How to: Convert a Decimal Number to a Base-256 dotted-decimal

Step

 

1

Evaluate the number:

  • If the decimal number is >= 256, then continue to step 2.
  • If the decimal number is less than 256, then use that decimal number for the 4th octet, and pad the rest with zeros so that the result is in dotted-decimal form, with four octets.

2

Divide the decimal number by 256

3

Multiply the decimal portion of the result from step 2 by 256

4

Subtract the result of step 3 from the original decimal number to yield the Base-256 octet

5

Examine the decimal portion of the result from step 2

  1. If that decimal portion of the number is less than 256, then use that number for the next octet.
  • Use zeroes for any remaining octets, so that the number is in dotted-decimal form.
  1. if that number is larger than, or equal to 256, then continue from step 2, using that number.

Example 1

Find the last address in an IPv4 subnet with a network address of 16.0.0.0 /17, with 32,768 addresses per subnet. (This network address is subnet zero.)

First, convert the number of addresses - 1 to Base 256 (dotted-decimal). 32,768 - 1 = 32,767

Convert 32,767 to Base-256 (dotted decimal):

  1. The number is larger than 256, so we have to process the number
  2. 32,767 / 256 = 127.996
  3. 127 x 256 = 32,512
  4. 32,767 – 32,512 = 255 (this is the 4th octet of the dotted decimal)
  5. Since 127 is smaller than 256 you're done dividing and the value for the 3rd octet is 127

Using zeroes for the remaining octets yields a Base-256 value of: 0.0.127.255

Once the conversion is complete, add that Base 256 dotted-decimal value to the 1st address to determine the last address in the subnet.

First address in the 1st subnet:

 

16

.

0

.

0

.

0

Number of addresses (32,768 per subnet) -1 :

 

0

.

0

.

127

.

255

Last address in the 1st subnet:

 

16

.

0

.

127

.

255

 


[ Top ] [ Home ]

 

How to: Convert an IPv4 Address to a Decimal Number

2563 2562 2561 2560
16,777,216 65,536 256 1
w x y z

An IPv4 address is a 32-bit number. It is generally written in the "dotted-decimal" notation: w.x.y.z. To convert an IP address to base 10, use the following:

w * 16,777,216 + x * 65,536 + y * 256 + z = Decimal IP Address

 


[ Top ] [ Home ]

 

All items Copyright ©1996 - 2017 Chin. All Rights reserved Reproduction without explicit permission is prohibited. See: Terms of use