Here you can find the source of getHost()
public static String getHost()
//package com.java2s; //License from project: Open Source License import java.net.Inet4Address; import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; import java.util.Enumeration; public class Main { /***// www . j av a 2s . c om * * @return */ public static String getHost() { try { Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); while (interfaces.hasMoreElements()) { NetworkInterface current = interfaces.nextElement(); if (!current.isUp() || current.isLoopback() || current.isVirtual()) continue; if (current.getName().contains("lxc")) continue; // <-- do not get LXC interfaces Enumeration<InetAddress> addresses = current.getInetAddresses(); while (addresses.hasMoreElements()) { InetAddress current_addr = addresses.nextElement(); if (current_addr instanceof Inet4Address) { return current_addr.getHostAddress(); } } } } catch (SocketException ex) { return null; } return null; } }