Python : Convert IPv6 address to decimal and back to IPv6
Problem :
Need to convert IPv6 address to decimal number and convert back to IPv6. How to do that?
Solution :
Use the netaddr.IPAddress()
function to convert IPv6 to decimal and back to IPv6.
For example :
// convert decimal number to IPv6 address
import netaddr
print str(netaddr.IPAddress(338288524927261089654163772891438416681))
Output :
fe80::202:b3ff:fe1e:8329
// convert IPv6 address to decimal number
import netaddr
print int(netaddr.IPAddress('fe80::202:b3ff:fe1e:8329'))
Output :
338288524927261089654163772891438416681
By Adam Ng
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+6.6k Golang : Random integer with rand.Seed() within a given range
+4.3k Golang : Accessing dataframe-go element by row, column and name example
+20.2k Golang : Gorilla mux routing example
+3.3k Swift : Convert (cast) Float to Int or Int32 value
+8.7k Golang : Search and extract certain XML data example
+11.1k Golang : Get digits from integer before and after given position example
+24.8k Golang : JQuery AJAX post data to server and send data back to client example
+25.9k Golang : Example for ECDSA(Elliptic Curve Digital Signature Algorithm) package functions
+8.6k Golang : How to convert a number to words
+35.5k Golang : How to read CSV file
+15.5k Golang : Reset or rewind io.Reader or io.Writer
+6.6k Android Studio : Checkbox for user to select options example