Finding out if your Python supports IPv6 sockets
IP version 6 or IPv6 is increasingly adopted by the industry to build newer applications. In case you would like to write an IPv6 application, the first thing you'd like to know is if your machine supports IPv6. This can be done from the Linux/Unix command line, as follows:
$ cat /proc/net/if_inet6 00000000000000000000000000000001 01 80 10 80 lofe80000000000000642a57c2e51932a2 03 40 20 80 wlo1
From your Python script, you can also check if the IPv6 support is present on your machine, and Python is installed with that support.
Getting ready
For this recipe, use pip
to install a Python third-party library, netifaces
, as follows:
$ pip install netifaces
How to do it...
We can use a third-party library, netifaces
, to find out if there is IPv6 support on your machine. We can call the interfaces()
function from this library to list all interfaces present in the system.
Listing 3.10 shows the Python IPv6 support checker, as follows:
#!/usr/bin/env...