To translate an IP address from a string of decimals (in little endian* order) into a real IP address, follow this procedure:

Using the decimal number 26999818 as an example.

1) Convert the number to hex

    26999818 (in dec) = 19BFC0A (in hex)

2) If the hex number is 7 digits long, add a leading 0. If the hex number is 8 digits, skip to step 3.
    => 019BFC0A (in hex)

3) Split this value into 4 bytes
     01 9B FC 0A

4) Reverse the order of the bytes, as this value is little endian*
    0A FC 9B 01

5) Convert each byte (in hex) back to decimal
    10 252 155 1

This is the real IP address in dot-decimal notation: 10.252.155.1


*The least significant byte (LSB) value, 0x01, is stored in memory at the lowest address. And the most significant byte (MSB) value, 0x0A, is stored in memory at the highest address.

Note: For a better understanding on "Endian", check out the explanation here.

0 comments