- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFakeDNSTest.java
More file actions
Latest commit
19 lines (16 loc) · 650 Bytes
/
Copy pathFakeDNSTest.java
File metadata and controls
19 lines (16 loc) · 650 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
importjava.net.InetAddress;
importjava.net.UnknownHostException;
//run with option --add-opens java.base/java.net=ALL-UNNAMED
publicclassFakeDNSTest {
publicstaticvoidmain(String[] args){
FakeDNSfakeDns=FakeDNS.getInstance();
fakeDns.install();
try {
fakeDns.addForwardResolution("test",InetAddress.getByName("192.168.142.2"));
System.out.println(InetAddress.getByName("www.163.com").getHostAddress());
System.out.println(InetAddress.getByName("test").getHostAddress());
} catch (UnknownHostExceptione) {
e.printStackTrace();
}
}
}