Here you can find the source of getAllMyHostAdresses()
public static Set<InetAddress> getAllMyHostAdresses() throws Exception
//package com.java2s; /*// w w w. java2 s. c o m * (C) Copyright IBM Corp. 2008 * * LICENSE: Eclipse Public License v1.0 * http://www.eclipse.org/legal/epl-v10.html */ import java.net.InetAddress; import java.net.NetworkInterface; import java.util.Enumeration; import java.util.HashSet; import java.util.Set; public class Main { public static Set<InetAddress> getAllMyHostAdresses() throws Exception { Set<InetAddress> addresses = new HashSet<InetAddress>(); Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); while (en.hasMoreElements()) { Enumeration<InetAddress> ias = en.nextElement().getInetAddresses(); while (ias.hasMoreElements()) addresses.add(ias.nextElement()); } return addresses; } }