Hi there,
Do you know how I could get one of the IPv6 adress of one of my interface in python2.6. I tried something with the socket module which lead me nowhere.
Thanks.
Hi there,
Do you know how I could get one of the IPv6 adress of one of my interface in python2.6. I tried something with the socket module which lead me nowhere.
Thanks.
You could just simply run 'ifconfig' with a subprocess.* call and parse the output.
The netifaces module should do it under Linux.
import netifaces
addrs = netifaces.ifaddresses('eth0')
addrs[netifaces.AF_INET6][0]['addr']
I'll surely go with this, it sould be working good, even if I find that really ugly.
step1 = Popen(['ip','addr','show','br0'],stdout=PIPE)
step2 = Popen(['grep','inet6'],stdout=PIPE,stdin=step1.stdout)
step3 = Popen(['sed','-e','/fe80/d','-e','s/ *inet6 *//g','-e','s/\/64.*$//g'],stdout=PIPE,stdin=step2.stdout)
step4 = Popen(['tail','-n1'],stdout=PIPE,stdin=step3.stdout)
step4.communicate()[0]
Thanks for the help again.