// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.net.*;
import java.util.*;

public class LocalhostExt {
    public static void main(String[] args) throws Exception {
         Enumeration e = NetworkInterface.getNetworkInterfaces();
         while(e.hasMoreElements()) {
            NetworkInterface ni = (NetworkInterface)e.nextElement();
            System.out.println("Net interface: " + ni.getName());
            Enumeration e2 = ni.getInetAddresses();
            while (e2.hasMoreElements()){
               InetAddress ip = (InetAddress)e2.nextElement();
               System.out.println("IP address: " + ip.getHostAddress());
            }
         }
    }
}
