import java.net.InetAddress;

public class SimpleDNS {

    public static void main(String[] args) {
        getAllDNS();
        getDNS();
    }

    private static void getAllDNS() {
        try {
            InetAddress[] address = InetAddress.getAllByName("www.google.com");
            for (int i = 0; i < address.length; i++) {
                System.out.println(address[i].getHostAddress());
            }
        } catch (Exception e) {
            System.out.println(e.toString());
            System.exit(1);
        }
    }

    private static void getDNS() {
        try {
            InetAddress address = InetAddress.getByName("mdm.zte.com.cn");
            System.out.println(address.getHostAddress());
        } catch (Exception e) {
            System.out.println(e.toString());
            System.exit(1);
        }
    }

}
getAllDNS获取域名解析的所有IP地址
getDNS获取域名解析地址单个
 

相关文章:

  • 2021-11-30
  • 2022-01-01
  • 2021-12-02
  • 2021-12-03
  • 2021-12-15
  • 2021-11-17
  • 2022-12-23
猜你喜欢
  • 2021-11-30
  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
  • 2022-12-23
  • 2021-09-30
相关资源
相似解决方案