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

2
  • 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. Mar 19 '16 at 10:32
  • 1
    This is also true for the current git sources. (Which I suspect are what Harald checked.) Mar 19 '16 at 11:34
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.