IPv6 vs IPv4


I am debugging my terraform script to create an IPv6 gateway and tunnel. But what is IPv6? AND what is IPv4?   T

IPv4 has 32 bit addresses so there are 2^32 available ip addresses. All of these are almost used up, so a few years ago IPv6 was introduce – 128 bit addresses 2^128 addresses are available. Obviously that is a lot more.  The networks run parallel and you need a gateway that turns your ipv4 packet into IPv6 (I think) I could be wrong here.  The packet structure is different as is the address name space.

When we are talking about IPv4 and IPv6 gateways we are talking about sockets.

Lets take a look at python sockets!

serversocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serversocket.bind((socket.gethostname(), 80))

This opens a socket on port 80.AF_INET refers to IPv4. (like a http server) If I wanted to open a socket on IPv6 I would use socket.AF_INET6.

In this case I bind the socket to an address like localhost or – or a 128 bit IPv6 address.

AF_INET returns a 2 tuple – and address and port. AF_INET6 returns a 4 tuple: address, port, flow info, scope id.    Support for flow info and scope id is part of the protocol that makes these two incompatible.

What about the rest of the packet? I think I need to do some socket programming to truly gain intuition.


Leave a Reply