ustcweizhou edited a comment on issue #3311: Issues when multiple management IP addresses are set in the KVM hypervisor (with fix) URL: https://github.com/apache/cloudstack/issues/3311#issuecomment-506981342 @rhtyd I tested the following java code in centos6, centos7, ubuntu12 and ubuntu16. It lists all devices and ips in reverse order as "ip a". So I think it is better to reverse the ip addresses as usually we use the first ip of nics for communication. ListNetworkAddresses.java ``` import java.net.InterfaceAddress; import java.net.NetworkInterface; import java.util.Collections; import java.util.List; public class ListNetworkAddresses { public static void main(String[] args) throws Exception { final List<NetworkInterface> nics = Collections.list(NetworkInterface.getNetworkInterfaces()); for (final NetworkInterface nic : nics) { final List<InterfaceAddress> addrs = nic.getInterfaceAddresses(); if (addrs != null) { for (final InterfaceAddress addr : addrs) { System.out.println("network device name is " + nic.getName() + ", ip is " + addr.getAddress().getHostAddress()); } } } } } ``` command ``` javac ListNetworkAddresses.java && java ListNetworkAddresses ```
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services