Skip to content

Commit 6f9a9e6

Browse files
authored
add egress diagnostic util (#54)
1 parent dded1a2 commit 6f9a9e6

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package test;
2+
3+
import java.net.*;
4+
5+
public class EgressDiagnostics {
6+
public static void main(String[] args) throws SocketException {
7+
System.out.println(System.getProperties());
8+
tryRemote(new InetSocketAddress("a.root-servers.net", 0));
9+
tryRemote(new InetSocketAddress("a.root-servers.net", 53));
10+
tryRemote(new InetSocketAddress("1.1.1.1", 0));
11+
tryRemote(new InetSocketAddress("1::1", 0));
12+
}
13+
14+
public static void tryRemote(InetSocketAddress remote) {
15+
DatagramSocket socket = null;
16+
try {
17+
System.out.println("\nremote: " + remote);
18+
socket = new DatagramSocket();
19+
socket.connect(remote);
20+
InetAddress local = socket.getLocalAddress();
21+
System.out.println("local: " + local);
22+
NetworkInterface ni = NetworkInterface.getByInetAddress(local);
23+
System.out.println("interface: " + ni);
24+
System.out.println("hardware: " + ni.getHardwareAddress());
25+
} catch (Throwable t) {
26+
System.out.println(t);
27+
t.printStackTrace();
28+
} finally {
29+
if (socket != null) {
30+
socket.close();
31+
}
32+
}
33+
}
34+
}

0 commit comments

Comments
 (0)