4

I want to find the IP addresses of all network interfaces in an elisp program. I tried this:

  (mapcar
   (lambda (if)
     (cons (car if) (network-interface-info (car if))))
   (network-interface-list))

However, when a network interface has both an IPv4 and an IPv6 address, the above only lists the IPv4 address. Is there a way to access the IPv6 address from elisp? (I'd rather avoid parsing the output of ifconfig.)

Drew
  • 75,699
  • 9
  • 109
  • 225
legoscia
  • 6,012
  • 29
  • 54
  • 1
    From a bit of poking around in the C source code (`process.c`) it appears that the answer is no. There is plenty of code dealing with IPv6 there, but the implementation of `network-interface-info` seems to be an exception. – Harald Hanche-Olsen Mar 19 '16 at 10:32
  • 1
    This is also true for the current git sources. (Which I suspect are what Harald checked.) – Jon Kåre Hellan Mar 19 '16 at 11:34

1 Answers1

2

No, this is not possible directly from Elisp at the moment.

Please open a bug report, so that this feature can be added (it won't be in time for Emacs 25, but it may make it to the next version).

In the meantime, depending on your platform, you can call out to external programs such as ip -6 addr.

Clément
  • 3,924
  • 1
  • 22
  • 37