IP Address Conversion

Contents


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

This is useful to determine a high subnet address when the Block Size increment is not practical. e.g. What’s the subnet address of the 4096th subnet?

  • If you start counting subnets from zero, then multiply the target Subnet # by the number of addresses per subnet, to determine how many addresses to add to the 1st subnet/subnet-zero, to jump to the target subnet.
    • Note: If you start counting subnets from 1, e.g. 1st, 2nd, 3rd, etc., then multiply the (target Subnet – 1) by the number of addresses per subnet.
  • Convert the result to the Base-256 dotted-decimal equivalent.
  • Pad the rest with zeros so that the result is in dotted-decimal form, with four octets.
  • Add that Base-256 dotted-decimal equivalent to the 1st subnet, to get the IP address of the target subnet.
Step 
1Evaluate 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 octet.
2Divide the decimal number by 256
3Multiply the integer portion of the result from step 2 by 256
4Subtract the result of step 3 from the original decimal number to yield the Base-256 octet
5Use the integer result from step 2, as the starting point for the next octet, then start at step 1 for the octet.

Example 1

What is the IPv4 network address of the last subnet, for the classless network 16.0.0.0 /17, with a total of 512 subnets?

  • 2<bits borrowed> = # of subnets: 512 subnets = 29 (9 bits borrowed)
  • /17 + 9 bits borrowed = a new mask of /26
  • Since we start counting from zero, the subnet # range is 0 – 511. So the the last, and target, subnet is Subnet # 511
  • 32 IPv4 bits – 26 network bits = 6 host bits. 26 = 64 addresses per subnet
  • Subnet #511 x 64 addresses per subnet = 32,704 addresses that must be added to subnet zero to jump to the target subnet.

Convert 32,704 to Base-256 (dotted decimal)

Forth Octet

  1. Evaluate the number: The number is larger than 256, so we can process the number
  2. 32,704 / 256 = 127.75
  3. 127 x 256 = 32,512
  4. 32,704 – 32,512 = 192 (is the 4th octet of the dotted decimal)

Third Octet

  1. We start with the integer from Part 1, 127. Evaluate the number: The number is not larger than 256, so we cannot process the number.
  2. 127 (Is the 3rd octet)

The Base-256 dotted equivalent of 32,704, is 0.0.127.192, which is what we add to subnet zero to determine the 512th subnet

16.0.0.0 + 0.0.127.192 = 16.0.127.192

Example 2

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

  1. Evaluate the number: The number is larger than 256, so we can 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

  • The 255 is from step 4, and the 127 is what was left over, and the 0’s fills out the dotted-decimal.

Examples


How to: Convert an IPv4 Address to a Decimal Number

2563256225612560
16,777,21665,5362561
wxyz

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

Review Your Cart
0
Add Coupon Code
Subtotal
Total Installment Payments
Bundle Discount