After the DNS query results are cached, the successful result is permanently cached, the failure result is cached 10s, the following method to set the success and failure of the cache time
//0 is not cached,-1 is never expired, other units are S
Security.setproperty ("Networkaddress.cache.ttl", "10");
Security.setproperty ("Networkaddress.cache.negative.ttl", "3");
//If an IP address is passed in, no DNS query is made
InetAddress address=inetaddress.getbyname ("www.baidu.com");
//inetaddress.getbyname () Incoming IP address, and then call GetHostName () will not be abnormal because of query DNS failure
System.out.println (Address.gethostname ()); //www.baidu.com
System.out.println (Address.gethostaddress ()); //180.97.33.107
System.out.println (Arrays.tostring (Address.getaddress ())); //[-76, 107]
System.out.println (Address.tostring ()); //www.baidu.com/180.97.33.107
Equals () Having the same IP address is equal; Hashcode () calculated based on IP address
System.out.println (Address.equals (address2));
System.out.println (Address.hashcode ());
//test whether the machine is accessible via the Echo port
Address.isreachable (1000);
//Get information about the hardware network Port
NetworkInterface inter=networkinterface.getbyname ("Eth3");
System.out.println (Inter.getdisplayname ());
System.out.println (Inter.getname ());
Java Network Programming 1-Querying Internet addresses