목차

Java Network

Java Network Property

DNS Cache

Localhost의 IP 주소 목록 뽑기

Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces();
 
List<String> localIps = Lists.newArrayList();
 
while (networkInterfaces.hasMoreElements()) {
    NetworkInterface networkInterface = networkInterfaces.nextElement();
    Enumeration<InetAddress> inetAddresses = networkInterface.getInetAddresses();
 
    while (inetAddresses.hasMoreElements()) {
        InetAddress inetAddress = inetAddresses.nextElement();
        if (!inetAddress.isLoopbackAddress() && !inetAddress.isLinkLocalAddress() && inetAddress.isSiteLocalAddress()) {
            localIps.add(inetAddress.getHostAddress());
        }
    }
}

IP Address match

java.net.URL

IPv4 강제하기

-Djava.net.preferIPv4Stack=true

위 항목을 Java Code에서 지정하면 작동하지 않고, java 명령행에서 지정해야만 한다.