Get list of IPv6 addresses of an interface

  • Permalink
  • submit to reddit
  • Email
  • Follow


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
Reply fernando.gont (1) 11/29/2011 7:12:06 AM

See related articles to this posting


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
Reply 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
Reply lacos2 (200) 12/1/2011 6:04:15 PM
comp.unix.programmer 10664 articles. 64 followers. Post

2 Replies
1005 Views

Similar Articles

[PageSpeed] 0


  • Permalink
  • submit to reddit
  • Email
  • Follow


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 ...

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...

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]; ...

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...

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 ...

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...

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 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...

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 ...

Need to extract email addresses from Global Address List Distribution LIst
Greetings, I am using CDO.Message to send email messages from my application. I now need to send email to existing distribution lists in our Global Address List. However, our exchange server blocks sending to distribution list (i.e. distribution list is named MyDistList and its email address is MyDistList@mycompany.com) from SMTP email. I have searched in vain for an example of VBA that will extract the email addresses of members of a distribution list from the Global Address List with a specific name. (I have found code that will use a DL in the contacts but that doesn't help). ...

how to get the MAC address of a network interface ?
Hi all, Thanks Hi > Hi all, I posted this sometime ago here look on older messages regards Luiz On 22 Gen, 17:13, "fatfat" <fat...@fatfat.com> wrote: > Hi all, > > Thanks Hi Bellow the source that add an news function that return all the mac address of an machine on an array /* Author luiz Rafael Culik Guimaraes */ #include <Windows.h> #include <Iphlpapi.h> #include <Assert.h> #include "hbapi.h" #include "hbapiitm.h" HB_FUNC(GETMACADDRESS) { IP_ADAPTER_INFO AdapterInfo[16]; // Allocate information for u...

Get a list of network interfaces in PHP?
Hi All, I've got a utility I'm working on, and I want to be able to list for the user all the current network interfaces on the machine. Is there a way to do this in PHP? PHP 5.0.3, Mandriva Linux 2005 (2.6 kernel). I'm not actually in front of the machine in question, and I don't recall the minor kernel version, or the minor version of Mandriva... Any thoughts? I'd prefer not to have to run the script as root, incidentally. I realize I could run as root and then just parse the output of ifconfig, but I assume there's a more intelligent way to go about what I'...

how to get mac address of network interfaces
the Question is how to get the mac adress of NOT plumbed network interfaces. It is easy to get mac addr. of plumbed interfaces (ifconfig -a) but what about not plumbed interfaces. the local-mac-address? is set to true. Thx potros mohm senad wrote: > the Question is how to get the mac adress of NOT plumbed network > interfaces. > > It is easy to get mac addr. of plumbed interfaces (ifconfig -a) but > what about not plumbed interfaces. > May be 'arp' is your friend On Mon, 07 Feb 2005 20:00:43 +0100, PM <pm@gmx.de> wrote: >mohm senad wrote: >> t...

How to get a list of printers with their device address
Hi my goal is to identify the lan printers which do not have an internet name in RMTLOCNAME parameter into their device description. For that, I need to produce a file (or a list) containing the device name and its RMTLOCNAME parameter All the lan printers name start with P, so the list will look like that: PSGJGG 192.168.10.55 PKHKHKJ 192.168.10.75 PGDGDGD PDNSNAM01 I've tried a lot of thing : - like found here http://itknowledgeexchange.techtarget.com/itanswers/as400-printer-ip-address-listing/ but it do not fit my needs. I do not succeed in getting that file/list. Thank you fo...

how to get interface list using ioctl
I have been trying to get all the interface list and ip addresses on my AIX box.....but it doesn't seem to work.......also I am unable to get the stateless ip addresses for IPV6 ....any help or suggestions how to do it........Below is my code....... #include <sys/types.h> #include <sys/socket.h> #include <sys/ioctl.h> #include <netdb.h> #include <netinet/in.h> #include <unistd.h> #include <net/if.h> #include <arpa/inet.h> #include <stdio.h> #include <string.h> #define num 5 int n; int main(){ int sd,err,ifsize; struct ...

Get list of all IP Addresses on AIX
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]; ...

OT: getting spammed to my list address
Hi All: sorry for the off-topic post, but I was just curious about something. I set up a unique mail account to access this list, and within 2 weeks of using it I started getting bombarded with spam. Is that a function of spammers setting up bogus accounts on bind-users and harvesting the address of anyone posting? Or are posts on this list being picked up in archives and are exploitable that way? Or both? I can change addresses and resubscribe but it's kind of a drag to have to do it every two weeks <g>. I have unique addresses subscribed to > 20 user lists and non...

IPv6 address format -interface identifier
Hello, I would like to know if there is any specific reason for the convention of complementing the Universal/Local bit of the IEEE EUI-64 identifier to obtain the interface or host identifier part of IPv6 address on an ethernet. Thanks and Regards, Prashant Prashant Varghese <pvsnmp@yahoo.com> wrote: > Hello, > I would like to know if there is any specific reason for the > convention of complementing the Universal/Local bit of the IEEE EUI-64 > identifier to obtain the interface or host identifier part of IPv6 > address on an ethernet. You will find di...