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
+9.9k Golang : Use regular expression to get all upper case or lower case characters example
+10.1k Golang : Simple Jawi(Yawi) to Rumi(Latin/Romanize) converter
+5.3k Golang : Display advertisement images or strings on random order
+9.5k Golang : ffmpeg with os/exec.Command() returns non-zero status
+17.3k Golang : delete and modify XML file content
+12.6k Golang : http.Get example
+6.7k Golang : constant 20013 overflows byte error message
+9.8k CodeIgniter : Load different view for mobile devices
+8.6k Golang : Gaussian blur on image and camera video feed examples
+7.7k Golang : Check from web if Go application is running or not
+5.8k Golang : Missing Subversion command
+7.1k Golang : Accessing dataframe-go element by row, column and name example