younis
younis

Reputation: 21

is a python converted ipv4 address to ipv6 is usable in real devices

I am almost new to some parts of Python especially in IP Address modules. I am working with Netaddr module. This module has a bunch of functions IPAddress, IPNetwork… My question is that: we can change an IPV4 Address to IPV6 address by using Netaddr module as follow

IPV4_ADDR = netaddr.IPAddress(u'192.168.1.1')
print(IPV4_ADDR.ipv6())
output= ::ffff:192.168.1.1

is output is acceptable IPV6 Address in real devices or not?

Upvotes: 1

Views: 1025

Answers (1)

Sander Steffann
Sander Steffann

Reputation: 9978

No, it is not. The address you show is what is used in applications that accept IPv4 connections on an IPv6 socket. Because it is an IPv6 socket the IPv4 address has to be represented in IPv6 format. That format is only valid within your application, not on a real network.

IPv4 and IPv6 are separate protocols. There is no way to convert addresses from one to the other. Some systems have only IPv4 addresses, some only IPv6 addresses, some have a mix like one IPv4 address with NAT and three IPv6 addresses without NAT (a very common case).

For a server you use hostnames and DNS to advertise which IPv4 and IPv6 addresses can be used to reach the server. A client will lookup the hostname in DNS to determine what mix of addresses is available and then connect to them based on what types of connectivity it has available. Some applications (mostly web browsers) use an algorithm called Happy Eyeballs to quickly switch between IPv4 and IPv6 in case of networking problems so that the user always gets the best experience and never needs to know anything about networking protocols.

Upvotes: 3

Related Questions