Created
July 14, 2013 11:58
-
-
Save nfisher/5994058 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.net.NetworkInterface; | |
import java.util.Enumeration; | |
public class NetIf { | |
public static void main(String [] args) { | |
try { | |
Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); | |
while (en.hasMoreElements()) { | |
NetworkInterface nif = en.nextElement(); | |
Enumeration<NetworkInterface> suben = nif.getSubInterfaces(); | |
while (suben.hasMoreElements()) { | |
System.out.println(suben.nextElement().getName()); | |
} | |
System.out.println(nif.getName()); | |
} | |
} catch(Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ifconfig -u | |
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384 | |
# loopback device no status req'd | |
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 | |
status: active | |
p2p0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 2304 | |
status: inactive | |
en3: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500 | |
status: inactive | |
$ java NetIf | |
en0 | |
lo0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment