473,659 Members | 2,664 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Convert IPv4 to IPv6

Hi,

is there a straight forward way of converting IPv4 to IPv6?

I thought that it was just a matter of converting 32 bits to 128 bits, (by
adding 96 leading 0s), but that does not seem right in some/most cases.

For example, 127.0.0.1, (IPv4 localhost), does not convert ::1, (IPv6
localhost)

so, is there a function/script/technique to convert IPv4 to IPv6?

Thanks

Simon

Aug 13 '08 #1
14 9263
I don't know the math as I don't deal with networking anymore. You
could try splitting IP4 into it's octets and apply the math like that
then reassemble.

Aug 13 '08 #2
..oO(Simon)
>is there a straight forward way of converting IPv4 to IPv6?
Have a look at the IPv6 RFC and/or its Wikipedia entry. IIRC there's an
address range reserved for mapping the old IPv4 addresses.
>I thought that it was just a matter of converting 32 bits to 128 bits, (by
adding 96 leading 0s), but that does not seem right in some/most cases.
It's a totally different numbering system.

Micha
Aug 13 '08 #3
>
>>is there a straight forward way of converting IPv4 to IPv6?

Have a look at the IPv6 RFC and/or its Wikipedia entry. IIRC there's an
address range reserved for mapping the old IPv4 addresses.
Yes, I had a look at it, and my impression was that IPv6 was the successor
of IPv4 so 32bits had been reserved to allow for backward compatibilities .
>
>>I thought that it was just a matter of converting 32 bits to 128 bits, (by
adding 96 leading 0s), but that does not seem right in some/most cases.

It's a totally different numbering system.
I wouldn't go as far as asying 'totally'.

127.0.0.1 -01111111.000000 00.00000000.000 00001 ->
011111110000000 0:0000000000000 001 - 7f00:0001
Micha
Simon

Aug 13 '08 #4
>I don't know the math as I don't deal with networking anymore. You
could try splitting IP4 into it's octets and apply the math like that
then reassemble.
That was my first impression.
But given that the range 127.0.0.0/8 is reserved for loopback and ::1 does
fall within the range 127.0.0.0/8.
it makes me think that the conversion is not as straight forward as I would
have thought, (as 127.0.0.1 is ::7f00:1)

Simon

Aug 13 '08 #5
..oO(Simon)
>>>is there a straight forward way of converting IPv4 to IPv6?

Have a look at the IPv6 RFC and/or its Wikipedia entry. IIRC there's an
address range reserved for mapping the old IPv4 addresses.

Yes, I had a look at it, and my impression was that IPv6 was the successor
of IPv4 so 32bits had been reserved to allow for backward compatibilities .
Reserving 32 bits would drastically reduce the address space. But the
range ::ffff:0:0/96 seems to be reserved for the old IPv4 addresses. It
shouldn't be too difficult to do the mapping.

http://en.wikipedia.org/wiki/IPv4_mapped_address
>>>I thought that it was just a matter of converting 32 bits to 128 bits, (by
adding 96 leading 0s), but that does not seem right in some/most cases.

It's a totally different numbering system.

I wouldn't go as far as asying 'totally'.

127.0.0.1 -01111111.000000 00.00000000.000 00001 ->
01111111000000 00:000000000000 0001 - 7f00:0001
Sure, but in IPv6 the loopback device is ::1, which has nothing to do
with 127.0.0.1 or 7f00:0001 (which is not even valid IPv6, BTW). The
same applies to the old local addresses like 192.168.x.y for example.

Micha
Aug 13 '08 #6
On Wed, 13 Aug 2008 22:00:28 +0200, Michael Fesser wrote:
.oO(Simon)
>>>>is there a straight forward way of converting IPv4 to IPv6?

Have a look at the IPv6 RFC and/or its Wikipedia entry. IIRC there's
an address range reserved for mapping the old IPv4 addresses.

Yes, I had a look at it, and my impression was that IPv6 was the
successor of IPv4 so 32bits had been reserved to allow for backward
compatibiliti es.

Reserving 32 bits would drastically reduce the address space. But the
range ::ffff:0:0/96 seems to be reserved for the old IPv4 addresses. It
shouldn't be too difficult to do the mapping.

http://en.wikipedia.org/wiki/IPv4_mapped_address
>>>>I thought that it was just a matter of converting 32 bits to 128 bits,
(by adding 96 leading 0s), but that does not seem right in some/most
cases.

It's a totally different numbering system.

I wouldn't go as far as asying 'totally'.

127.0.0.1 -01111111.000000 00.00000000.000 00001 ->
0111111100000 000:00000000000 00001 - 7f00:0001

Sure, but in IPv6 the loopback device is ::1, which has nothing to do
with 127.0.0.1 or 7f00:0001 (which is not even valid IPv6, BTW). The
same applies to the old local addresses like 192.168.x.y for example.
Things that are different aren't the same.

--
I told you this was going to happen.

Aug 13 '08 #7
>>
>Sure, but in IPv6 the loopback device is ::1, which has nothing to do
with 127.0.0.1 or 7f00:0001 (which is not even valid IPv6, BTW). The
same applies to the old local addresses like 192.168.x.y for example.

Things that are different aren't the same.
???

Simon
Aug 13 '08 #8
>>>>is there a straight forward way of converting IPv4 to IPv6?
>>>
Have a look at the IPv6 RFC and/or its Wikipedia entry. IIRC there's an
address range reserved for mapping the old IPv4 addresses.

Yes, I had a look at it, and my impression was that IPv6 was the successor
of IPv4 so 32bits had been reserved to allow for backward compatibilities .

Reserving 32 bits would drastically reduce the address space. But the
range ::ffff:0:0/96 seems to be reserved for the old IPv4 addresses. It
shouldn't be too difficult to do the mapping.

http://en.wikipedia.org/wiki/IPv4_mapped_address
yeah, but some source say that the notation has been deprecated.
in fact my Vista picks up ping ::7f00:1 as ping 127.0.0.1
but it does the same for ping ::ffff:7f00:1
>>
127.0.0.1 -01111111.000000 00.00000000.000 00001 ->
0111111100000 000:00000000000 00001 - 7f00:0001

Sure, but in IPv6 the loopback device is ::1, which has nothing to do
with 127.0.0.1 or 7f00:0001 (which is not even valid IPv6, BTW). The
same applies to the old local addresses like 192.168.x.y for example.
Si was converting as an example from decimal to binary and so forth, and
there were only 32 bits in my example not 128,
So the whole thing was not really going to be valid IPv6.
Micha
Simon

Aug 13 '08 #9
..oO(Simon)
>Reserving 32 bits would drastically reduce the address space. But the
range ::ffff:0:0/96 seems to be reserved for the old IPv4 addresses. It
shouldn't be too difficult to do the mapping.

http://en.wikipedia.org/wiki/IPv4_mapped_address

yeah, but some source say that the notation has been deprecated.
in fact my Vista picks up ping ::7f00:1 as ping 127.0.0.1
but it does the same for ping ::ffff:7f00:1
According to RFC 4291 the first version is deprecated.

http://tools.ietf.org/html/rfc4291#section-2.5.5

Micha
Aug 13 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1787
by: Agent | last post by:
I would like to invite you and your associates to attend the US IPv6 (Internet Protocol version 6) Summit, December 8-11, 2003 in Crystal City, VA, near the Pentagon. This major opportunity to participate in transitioning to the new Internet is in response to both DoD and Industry requests for a concentrated, affordable conference in the Washington, D.C. area. This exciting and informative conference on the Next Generation Internet will...
7
5925
by: Torsten Schmidt | last post by:
Hi, I'm trying to connect to a mysql-Server using PHP's mysql-function mysql_connect. The host on which the mysql-server is running is not the same as the host apache and php are running on. The two computers are connected in an IPv6-network. No matter if I give the hostname (defined in /etc/hosts), the IPv6-address ("fec0::4") or the IPv6-address in square brackets ("") the function mysql_connect always prints "Unknown MYSQL-Server "....
2
6381
by: PaulH | last post by:
I am attempting to write a functon that can perform IPv6 compliant pings. But, Icmp6SendEcho2 causes an access violation whenever it is called: First-chance exception at 0x76d641e8 in mping2.exe: 0xC0000005: Access violation reading location 0x00000000. Unhandled exception at 0x76d641e8 in mping2.exe: 0xC0000005: Access violation reading location 0x00000000. I have been unable to pinpoint the cause of the access violation so far, so I...
0
1305
by: Jason | last post by:
I've got a program that wil convert an IP address to decimal. Anyone give me any infor on how I would modify this program that I had converting regular IPs to decimal, hwo would I make it work for an IPv6 address? Would I add just 8 instances of converting ? Thanks for any help.... Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
65
21403
by: kyle.tk | last post by:
I am trying to write a function to convert an ipv4 address that is held in the string char *ip to its long value equivalent. Here is what I have right now, but I can't seem to get it to work. #include <string.h> #include <stdio.h> /* Convert an ipv4 address to long integer */ /* "192.168.1.1" --> 3232235777 */ unsigned long iptol(char *ip){
3
6104
by: fusillo | last post by:
hi, i would like know about mysql's ipv6 support, i installed mysql 5.0.19 from a source dist and no configuration option is provided to enable ipv6. do you know some tips about? regards fusillo
2
9422
by: Valerie Hough | last post by:
My app has so far only encountered IPv4 addresses and I use: Dns.GetHostByName( "someOtherComputer", portNumber ).AddressList. Can someone please point me to an example of how to turn this into an IPv6 address? Thanks in advance. Chris Hough
2
3718
by: Prabhu Gurumurthy | last post by:
Hello list, I would like to parse IPv6 addresses and subnet using re module in python. I am able to either parse the ipv6 address or ipv6 network but not both using single line. any help appreciated. BTW is there a metacharacter for hex digits. Thanks Prabhu -
1
2483
by: =?Utf-8?B?V2lsbGlhbSBSYW5kbGV0dA==?= | last post by:
The System.Uri class is not behaving as I expect when an IPv4 address is embedded within an IPv6 address. The following test works fine, using IPv6 only: public void Uri_ShouldCreateValidUriFromSimpleIPv6Address() { Uri testUri = new Uri("http://:9050"); Assert.AreEqual( "http://:9050/", testUri.ToString());
0
8427
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8330
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8850
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.