January 2019
Beginner to intermediate
776 pages
19h 58m
English
We can use the netifaces and netaddr third-party libraries to find out the IPv6 prefix information for a given IPv6 address.
Make sure to have netifaces and netaddr installed in your system:
$ pip install netaddr
The program is as follows:
#!/usr/bin/env python # Python Network Programming Cookbook, Second Edition -- Chapter - 3 # This program is optimized for Python 2.7.12 and Python 3.5.2. # It may run on any other version with/without modifications. # This program depends on Python modules netifaces and netaddr. import socket import netifaces as ni import netaddr as na def extract_ipv6_info(): """ Extracts IPv6 information""" print ("IPv6 support built into Python: %s" %socket.has_ipv6) for interface in ni.interfaces(): ...Read now
Unlock full access