java.net.NetworkInterface.getNetworkInterfaces() not listing all interfaces for OS X
Asked Answered
P

0

1

https://mcmap.net/q/645511/-networkinterface-getnetworkinterfaces-not-listing-all-interfaces provides a solution for Linux. I am looking for a similar solution for OS X, but not sure which files to read to get the list of Interfaces (file /proc/net/dev in linux) and then their HardwareAddresses (file /sys/class/net/devicename/address in linux).

My ultimate goal is to list Mac-Addresses of all the NetworkInterfaces (which gets listed as result of ifconfig command) on OS X implemented in pure Java.

Pucka answered 4/12, 2018 at 17:21 Comment(5)
Do you want to list network interfaces which are not active or are unconfigured?Gerfalcon
Basically all the network interfaces which gets listed as part of ifconfig command, not sure whether unconfigured also get listed there.Pucka
Possible duplicate of NetworkInterface.getNetworkInterfaces() not listing all interfacesMonoculture
@Monoculture I have already linked that ticket, and that ticket/solution is specific to Linux. This question is specific to OS XPucka
@adhirohah i know you asked for Mac but is still the same thing you can't do it with only Java. Also on OS X there isn't a File where you can read this. As far as i know your only way will be doing a syscall and use the ifconfig bundled in OS X and pass its output back to Java. Or you may need to look up the source code of OS X's Version of ifconfig to find out from where it is getting its information if you wanna try this a good starting point will be github.com/apple/darwin-xnuMonoculture

© 2022 - 2024 — McMap. All rights reserved.