public static String getLocalAddressByDatagram() {
        try(final DatagramSocket socket = new DatagramSocket()){
            socket.connect(InetAddress.getByName("8.8.8.8"), 10002);
            return socket.getLocalAddress().getHostAddress();
        } catch (Exception e) {
            logger.error("Failed to retrieving ip address.", e);
        }
        return null;
    }
@Test
    public void testGetLocalAddressByDatagram() {
        String ip = NetUtils.getLocalAddressByDatagram();
        System.out.println("ip = " + ip);
    }