那能不能根据机器的一个IP,获得该机器已配置的所有IP呢

解决方案 »

  1.   

    肯定不能靠mac,可不可以往一个ip上写点东西,然后从其他ip上读
      

  2.   

    一个主机多个IP是如何实现的呢?如果只用一个网卡,那么你读一下自己的ARP表就能看到多个IP地址对应一个MAC地址。如果用多个网卡就不好办了,如果该主机直接连了可网管交换机,那就读那台交换机的转发表,看一个端口下对应了几个MAC地址。多个MAC自然就是多个网卡。
      

  3.   

    import java.net.InetAddress;
    import java.net.UnknownHostException;public class getip
    {
    public static void main(String[] args){
    try{
    InetAddress[] addresses=InetAddress.getAllByName("www.sina.com.cn");
    for(int i=0;i<addresses.length;i++){
    System.out.println(addresses[i].getHostAddress());
    }

    }
    catch(UnknownHostException uhe){
    System.err.println("Can not Find the ip");
    }


    }
    }
      

  4.   

    import java.net.InetAddress;
    import java.net.UnknownHostException;public class getip
    {
    public static void main(String[] args){
    try{
    InetAddress[] addresses=InetAddress.getAllByName("www.sina.com.cn");
    for(int i=0;i<addresses.length;i++){
    System.out.println(addresses[i].getHostAddress());
    }

    }
    catch(UnknownHostException uhe){
    System.err.println("Can not Find the ip");
    }


    }
    }