Get list of IPv6 addresses of an interface

Folks,

Is there any portable way of getting the list of IPv6 addresses for a
network interface?

sysctl() could have probably worked, but seems to be deprecated for
Linux. On the other hand, ioctl's SIOCGIFADDR only returns IPv4
addresses in Linux.

Thoughts?

Thanks,
Fernando



0
11/29/2011 7:12:06 AM
comp.unix.programmer 10764 articles. 0 followers. kokososo56 (349) is leader. Post Follow

2 Replies
1280 Views

Similar Articles

[PageSpeed] 8

Fernando Gont <fernando.gont@gmail.com> writes:
> Is there any portable way of getting the list of IPv6 addresses for a
> network interface?
>
> sysctl() could have probably worked, but seems to be deprecated for
> Linux. On the other hand, ioctl's SIOCGIFADDR only returns IPv4
> addresses in Linux.

Last time I looked into this there was no portable way.

On Solaris and HPUX I used SIOCGLIFCONF; on Linux, /proc/net/if_inet6;
on AIX, CSIOCIFCONF+SIOCGIFADDRS.  *BSD and OSX weren't required targets
so I didn't look into those; I think you can look at the source of
ifconfig for hints in those cases though.

Off-topic for this group, but on Windows I used GetAdaptersAddresses()
and my notes say that SIO_GET_INTERFACE_LIST looked like a reasonable
approach too, though I don't remember the details.

-- 
http://www.greenend.org.uk/rjk/
0
rjk (534)
11/29/2011 12:52:55 PM
On Mon, 28 Nov 2011, Fernando Gont wrote:

> sysctl() could have probably worked, but seems to be deprecated for 
> Linux. On the other hand, ioctl's SIOCGIFADDR only returns IPv4 
> addresses in Linux.

http://www.kernel.org/doc/man-pages/online/pages/man3/getifaddrs.3.html

perhaps?
0
lacos2 (200)
12/1/2011 6:04:15 PM
Reply:

Similar Artilces:

Get the ipv6 address from a interface
Hello, i need a function that returns the ipv6 address from a given interface name. For ipv4 i use this one: def get_ip_address(ifname): s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) return socket.inet_ntoa(fcntl.ioctl( s.fileno(), 0x8915, # SIOCGIFADDR struct.pack('256s', ifname[:15]) )[20:24]) which works great. But i am not enough into python to port that to ipv6. It has to work under linux only. Any help is appreciated. Greets, Kai In article <86176ef7-c2e0-4c5d-b883-d91672e3eb0b@w40g2000yqd.googlegroups.com>, Kai Timmer <email@kait.de&...

getting the wan address & lists of wifi interfaces.
Hi there, i've just 2 question: 1) Is there a way using standard ansi C (or using bash) to get the wan address of an interface? 2) """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" the list of the avaiable wifi interfaces? ...

Command for assigning IPv6 address and MAC address on the interface
HI Can anyone please tell me the command for assigning IPv6 address and mac address on a interface. I tried ifconfig eth0 inet6 add 2001:0db8:0:f101::1/64 It didnt work Is the command correct.? Cheers iceman wrote: > HI > > Can anyone please tell me the command for assigning IPv6 address and > mac address on a interface. > I tried > ifconfig eth0 inet6 add 2001:0db8:0:f101::1/64 > It didnt work > > Is the command correct.? It works for me... Have you checked that ipv6 is actually working? try: $ ifconfig eth0 You should see something like this if ipv6 is i...

Command for assigning IPv6 address and MAC address on the interface
HI Can anyone please tell me the command for assigning IPv6 address and mac address on a interface. I tried ifconfig eth0 inet6 add 2001:0db8:0:f101::1/64 It didnt work Is the command correct.? Cheers Hello, iceman a �crit : > > Can anyone please tell me the command for assigning IPv6 address and > mac address on a interface. man ifconfig man 8 ip > I tried > ifconfig eth0 inet6 add 2001:0db8:0:f101::1/64 > It didnt work Please can you elaborate ? How do you see it does not work ? > Is the command correct.? Yes, it works for me. You can also assign an IPv6 addres...

[newbie] getting the longest list from a list of lists
I'm just working through http://learnyouahaskell.com/ which is quite nice, and wanted to expand on one of the examples in the chapter on higher order functions when I hit a snag. The example is: chain :: (Integral a) => a -> [a] chain 1 = [1] chain n | even n = n:chain (n `div` 2) | odd n = n:chain (n*3 + 1) numLongChains :: Int numLongChains = length (filter isLong (map chain [1..100])) where isLong xs = length xs > 15 which gets me a list of numbers (a 'chain') for examining http://en.wikipedia.org/wiki/Collatz_conjecture and tells me ...

Get list of all IP addresses
I have been trying to get all ip addresses from all interfaces, with the code listed below. However, all I get is the 1st IP only. I have configured 2 IPs on a single interface, I want to get both from my c++ code. thanks svirdi #include <unistd.h> #include <stropts.h> #include <stdio.h> #include <stdlib.h> #include <sys/socket.h> #include <net/if.h> #include <sys/ioctl.h> //#include <sys/sockio.h> int main(int argn,char** argv) { int sock,n; struct ifreq *ifr; struct ifconf ifc; char buf[1024],addres[16]; ...

how to get my systems ipv6 address
hai.. i am working in windows Xp.i have set ipv6 to my system using 'ipv6 install' command. it shows installation completed.but if i check 'ipconfig' command it doesnt show any ipv6 address format,just shows only ipv4 address, can anyone help me.. And also if there is any sample Vc++ coding to reterive ipv6 address please send it.. waiting for ur replys.. Thanks in advance. ...

Manipulating interface IPv6 addresses
Hello to everybody, I'm writing an application that works like a sort of Router Advertisement Deamon for IPv6. I'm looking for a way to assign a (global) IPv6 address to an interface. I found somewhere you can do that via netlink. Is that the right way? Is there a simpler one? And where can I find detailed netlink documentation? I would be very happy if someone could help me!!! Greetings Max ...

List of lists of lists of lists...
I would like to have a list of lists N times deep, and my solution is (in pseudocode): def deep(x): a=[x] return a mylist=[] for N: mylist=deep(mylist) Is there a more elegant way to do it? The maine idea is: from a list having the numbre of steps along N dimensions, generate a list with an item at each possible point. Example 1: N=2 list=[2,3] result=[[1,2],[1,2],[1,2]] Example 2: N=3 list=[3,1,2] result=[[[1,2,3]],[[1,2,3]]] -- Ángel Gutiérrez Rodríguez - agr@fq.uniovi.es Instituto de Ciencia de los Materiales de Madrid - CSIC SpLine - European Syncrothorn Radiat...

get the list of network interfaces
Hello, All! I'd like to get the list of network interfaces available on the system (linux, kernel 2.4.20) in my C-program. Using 'ifreq' structure and appropriate 'ioctl' doesn't fit me, cause I should specify interface name in 'ifr_name' field, that's why I need %subj%. Thanks. With best regards, Roman Mashak. E-mail: mrv@tusur.ru Roman Mashak wrote: > > Hello, All! > > I'd like to get the list of network interfaces available on the system > (linux, kernel 2.4.20) in my C-program. > Using 'ifreq' s...

Getting logical interface addresses
Here is the code I have to get the interface address on Solaris 8 by passing on the interface name. What I am looking for is to get all the IP addresses configured on an interface, including any aliases. Can someone help me in getting the complete list? static uint32_t ifname_to_ip( char *ifname ) { struct ifreq ifr; int fd = socket(AF_INET, SOCK_DGRAM, 0); uint32_t addr = 0; if (fd < 0) return (-1); strncpy(ifr.ifr_name, ifname, sizeof(ifr.ifr_name)); if (ioctl(fd, SIOCGIFADDR, (char *)&ifr) == 0) { ...

Manipulating interface IPv6 addresses
Hello to everybody, I'm writing an application that works like a sort of Router Advertisement Deamon for IPv6. I'm looking for a way to assign a (global) IPv6 address to an interface. I found somewhere you can do that via netlink. Is that the right way? Is there a simpler one? And where can I find detailed netlink documentation? I would be very happy if someone could help me!!! Greetings Max "Massimiliano Marcon" <marcon@ira.uka.de> wrote in message news:d8mgpb$a1j$3@news2.rz.uni-karlsruhe.de... > I'm writing an application that works like a sort of Route...

Getting a printable IPv6 address
How do I get a printable IPv6 address (as obtained from getaddrinfo) without having a IPv6 stack installed? I tried ... struct addrinfo *ai; char buf[50] = "??"; DWORD buf_len = sizeof(buf); if (getaddrinfo("www.kame.net", "80", hints, &ai) == 0) { if (WSAAddressToString (ai->ai_addr, ai->ai_addrlen,NULL,buf,&buf_len)) puts ("failed"); } .... I only get WSAEINVAL from WSAAddressToString(), but fail to see that I've used it wrong. It works fine with an AF_INET address of course. I can see in tcpdu...

Manipulating interface IPv6 addresses
Hello to everybody, I'm writing an application that works like a sort of Router Advertisement Deamon for IPv6. I'm looking for a way to assign a (global) IPv6 address to an interface. I found somewhere you can do that via netlink. Is that the right way? Is there a simpler one? And where can I find detailed netlink documentation? I would be very happy if someone could help me!!! Greetings Max ...

Web resources about - Get list of IPv6 addresses of an interface - comp.unix.programmer

Postal addresses in the Republic of Ireland - Wikipedia, the free encyclopedia
Ireland is one of the few countries in the world, and the only EU country, that does not have a Postal code system. As of 2012, the Irish Government ...

How To: (Possibly) Restore Your Contacts After The Switch To Facebook.com Email Addresses
Still having issues with lost contacts following Facebook’s recent controversial move to make Facebook.com email addresses the default emails ...

Facebook Users Can Now Opt Into Letting Friends Export Their Email Addresses via Download Your Information ...
Previously, Facebook's Download Your Information tool let users export an archive of their status updates, photos, as well as a list of friends' ...

IPCC Chair Addresses Summit on Climate Change - Flickr - Photo Sharing!
Rajendra Pachauri, Chair of the Intergovernmental Panel on Climate Change (IPCC), addresses the opening plenary session of the Summit on Climate ...

Steve Jobs addresses Cupertino City Council - YouTube
Steve Jobs addresses Cupertino City Council

Twitter CEO Jack Dorsey Addresses VP Exodus
Several prominent Twitter executives recently left the company, including senior vice president of product Kevin Weil — a key member of the Project ...

Skype to hide IP addresses by default, protecting gamers everywhere
Microsoft has rolled out a new version of the desktop Skype client that should make users of its service a little safer from denial-of-service ...

Microsoft is finally hiding Skype users' IP addresses by default better late than never
Microsoft is a curious company sometimes. Quite often, it offers wonderful products, but then fails to truly focus on the details. A great example ...

Gas company CEO addresses Southern California gas leak
In his first interview since the Porter Ranch leak began, Southern California Gas Co. CEO Dennis Arriola says the danger has been overblown

Sharks 25th Anniv: Bettman addresses next hurdles for club
Enter to win prizes during the entire month of January! You can win tickets to a Warriors game, CSN studio tours, a chance to attend the Coaching ...

Resources last updated: 2/2/2016 11:46:21 PM