≡ Menu

Convert IPv4 into IPv6

I was going through 6to4 tunnel configs and thought I’d post some info on converting IPv4 address into IPv6 Address. This is pretty straight forward and its obviously involves HEX conversion.

Method 1 (Please also see Method 2 below as I think it is much more easier)

Here, I will convert the address

First we divide each octet by 16 and write down the remainder, primary school maths! 🙂

192 ÷ 16 = 12 remainder 0
168 ÷ 16 = 10 remainder 8
25 ÷ 16 = 1 remainder 9
234 ÷ 16 = 14 remainder 10

We also know that HEX has the following Values

A = 10
B = 11
C = 12
D = 13
E = 14
F = 15

So we can write into HEX like so… C0A8:19EA

Now we will change the HEX Address C0A8:19EA into regular IPv4

C0 = (12 x 16) + 0 = 192
A8 = (10 x 16) + 8 = 168
19 = (1 x 16) + 9 = 25
EA = (14 x 16) + 10 = 234


Method 2

Another easier way to convert is to convert the octets into Binary, in this case we will still use the IP address

Split those above 32Bit into equal 16 Bits as HEX is based on Base of 16, then Add them up.


IPv6 Link Local Address

Since we have converted the IPv4 address into hexadecimal, this can be written into the following 128-Bit IPv6 link-local address FE80:0000:0000:0000:0000:0000:C0A8:19EA which can be zero compressed into FE80::C0A8:19EA

And finally…

Hope I have explained it thoroughly so you could follow… If you have any doubts, feel free to add your comments.

Comments on this entry are closed.

  • Eryck

    I liked that. Nice and easy 🙂

  • Charlie


  • Rakesh

    Cool 😉

  • thanks .it was interesting.but would you please explain about subneting, for example /64 or /128?

  • javad

    thanks .it was interesting.but would you please explain about subneting, for example /64 or /128?

  • I will try and write one at the end of the month on IPv6 Subnetting.

  • parthasarathi.j

    how i config this ipv6 in linux. give an example cmd..

  • I know I am posting a comment in a very outdated post, but… since each address space is completely different, does it make any sense converting ipv4 ipv6? I mean, if we were to translate your ipv4 example address ( to an ipv6 one, it would look something like: 0000:0000:0000:0000:0000:0000:c0a8:19ea, which I guess it isn’t something wrong, but somewhat strange.

    Are you are actually extracting the ipv4 address contained in a 6to4 ipv6 address, isn’t it? (Because in other case, the conversion wouldn’t make sense)


  • It is how you look at the IP Address, and at the end of the day, v4 is 32Bit and v6 is 128Bit…

    Conversion is done for many reasons, for example v6 device trying to talk to a v4 Device, and only way they can understand each other is to convert the language (so to speak) they talk…

    Another example is a 6to4 Tunnel (RFC 3056) , where a conversion is needed…

    Also another practical example is, Imagine you have a cluster of Servers running on v4 and you want to transition to v6… Easy way to transition is to get the list of v4 Addresses, write a bit of Bash/PHP Script convert them to v6…

    Finally, a v6 address does look intimidating but when you apply Zero/Leading Zero compression, it does look rather presentable 🙂

    Hope it answers your question.

  • sanjeev


    thanks for that conversion seems very good, however in method 2 this line seems wrong

    9-14- (1110) (1010) 10- A this line should be

    E-14 (1110)(1010) 10-A

    Please let me know if this is just a typo as I see that the end result was correct

  • The 9 in the lower left corner of the last chart should be an E. E in hexadecimal = 14 in decimal = 1110 in binary.

  • rohit

    Thank’s Bro

  • Pale Writer

    Sorry I couldn’t get here sooner to proof this for you, but you SHOULD be getting the same result w/ method 2 as you did w/ method 1, as you’re “converting” the same source IPv4 address. The first cut rendered an 0xE correctly, but you show a 0x9 in the second.

    That ?type-O? aside, there remains a distinct shortage of information on the REST of IPv4IPv6 conversion which this little decimal-to-hex tutorial might logically have addressed.

    While this tickled some of your audience, once upon a time, this critic would prefer to hang with a different group, but – thanks for the effort.


  • Thank you very much for the Excellent information.

  • HoeZoWie

    Yeeh man, is it that easy ???
    This is far-most the best solution I ‘ve ever had under my eyes…
    Word Up Bro! You’re the best!

    Cheers for this, regards, best of luck in your life!

  • pijo

    nice..without software..tq 🙂

  • Bala

    Well nice. Thanks

  • Shaikmbasha

    how to convert normal ip to hexa for example

  • Agreed, nice. Could you go into a little bit more about the networking aspects of it and how a person could use that as a routable address, or is that already an address that a person could use publicly or privately to communicate?

  • Shoaib2love

    great job my dear thanks for this. This is mOre easiest form. regareds

  • Nifin K Antony

    Nice work…Thanks a lot..

  • Waleed Ahmed

    Really before i did not know how to convert ipv4 into hexa today i am please that i have learnt the conversion of hexa

  • Er Meetgill

    can you give any website to learn ipv6 

    • Hi, Er Meetgill
      Here is the weblink to  know abt IPV6:  http://en.wikipedia.org/wiki/I… 
      Here is the weblink to know how to convert ipv4 to ipv6:  http://www.nish.com/2009/11/co…
      Here is weblink to check How ur PC  IPV6 appears : http://test-ipv6.com/
      Hope this will be helpful to you

  • Hi, Er Meetgill

    Here is the weblink to  know abt IPV6:  http://en.wikipedia.org/wiki/IPv6 

    Here is the weblink to know how to convert ipv4 to ipv6:  http://www.nish.com/2009/11/convert-ipv4-into-ipv6/

    Here is weblink to check How ur PC  IPV6 appears : http://test-ipv6.com/

    Hope this will be helpful to you


  • Santosh Teli

    Thanks . This is a nice and very simple to understand…..!! 

  • mahmoud

    wallahy nice and beautifull……….thx my friend



  • Kpradeep27

    Thanks Nish !! Really awasome very simple to understand…

  • unu

    its 0000:0000:0000:0000:c0a8:19ea for ???

  • ram bhardwaj

    thank you sir.

  • Ravi Shankar

    My IP address is then what should be the IP6 format, when I checked it in my PC using ping command,it is showing like this fe80::6163:b701:73ca:602f. Could you help me to convert back to IP4

    • Chaitanya Krishna

      yes it is very easy

  • layth

    thank you .very simple methods

  • Chaitanya Krishna

    thank u for ur valuable information

  • satya

    its very good for freshers…….

  • KoyoS

    Thanks very much.

  • niki

    Thank u sir…it was very helpful..

  • Unknown

    Hi nish,

    Perfect explanation, but how do we make 32 bit addresses to 128 bit?
    Is it possible for you to elaborate where all we have to do the filling to as to make up 128 bit?

    Thanks in advance,

    • I have updated post and answered your question, do have a look.

  • peggy

    tnx a lot

  • Zobair Hamidy

    that was so useful, thank you 🙂

  • KT

    if we want to add subnets in your example above would that be? FE80::C0A8:19EA IPv6 address from FE80::/96 subnet? So all the converted IPv4 to IPv6 addresses are subjected to subnet FE80::/96?

Next post:

Previous post:

Copyright © Nish Vamadevan 2002-2017. All Rights Reserved. Terms and Policies.