Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the IPv6 address of an interface under linux

Tags:

python

linux

ipv6

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.

like image 891
jaes Avatar asked Aug 02 '10 14:08

jaes


People also ask

How do I find my IPv6 address in Linux?

Generic unix instructions for determining your IPv6 address and default route: Run ifconfig -a and look for inet6 to see your possible IPv6 addresses. Run netstat -nr and look for inet6 or Internet6 or similar to find the IPv6 portion; then look for default or :: or ::/0 .

How do I find my IPv6 interface ID?

The second part of an IPv6 unicast or anycast address is typically a 64-bit interface identifier used to identify a host's network interface. A 64-bit interface ID is created by inserting the hex value of FFFE in the middle of the MAC address of the network card.

How do I find IPv4 and IPv6 in Linux?

To check whether a CS Linux server is running IPv4 or IPv6, use the command ifconfig -a and look at the IP address or addresses in the output. These will be IPv4 dotted-decimal addresses, IPv6 hexadecimal addresses, or both.

How do I get an IPv6 address?

What You Will Need. Before you can request IPv6 addresses, you need to become a RIPE NCC member and open your Local Internet Registry (LIR) account. As part of this process, you will create a secure RIPE NCC Access account that allows you to request IP addresses and AS Numbers and maintain your LIR's information.


1 Answers

The netifaces module should do it.

import netifaces
addrs = netifaces.ifaddresses('eth0')
addrs[netifaces.AF_INET6][0]['addr']
like image 150
Mark Avatar answered Oct 17 '22 06:10

Mark