導航:首頁 > IDC知識 > 如何通過域名獲取ip

如何通過域名獲取ip

發布時間:2020-11-02 00:26:49

1、如何通過域名得到IP

最簡單的是通過:運行 > cmd > ping 域名 > 回車執行就可以得到該域名現在解析到什麼IP了;
第二種可以上http://www.ip138.com 這里查詢

2、java通過域名獲取IP地址

public String getIP(String name){
InetAddress address = null;
try {
address = InetAddress.getByName(name);
} catch (UnknownHostException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("獲取失敗");
}
return address.getHostAddress().toString();
}

3、如何通過ip地址查域名

你百度愛站,裡面有ip查詢,你會看到很多信息,裡面有域名

4、java怎麼通過域名獲取ip地址

import java.net.InetAddress;
import java.net.UnknownHostException;
public class TestInetAddress {
InetAddress myIpAddress = null;
InetAddress[] myServer = null;
public static void main(String args[]) {
TestInetAddress address = new TestInetAddress();
System.out.println("Your host IP is: " + address.getLocalhostIP());
String domain = www.jb51.net;
System.out.println("The server domain name is: " + domain);
InetAddress[] array = address.getServerIP(domain);
int count=0;
for(int i=1; i<array.length; i++){
System.out.println("ip "+ i +" "+ address.getServerIP(domain)[i-1]);
count++;
}
System.out.println("IP address total: "+count);
}
/**
* 獲得 localhost 的IP地址
* @return
*/
public InetAddress getLocalhostIP() {
try {
myIpAddress = InetAddress.getLocalHost();
} catch (UnknownHostException e) {
e.printStackTrace();
}
return (myIpAddress);
}
/**
* 獲得某域名的IP地址
* @param domain 域名
* @return
*/
public InetAddress[] getServerIP(String domain) {
try {
myServer = InetAddress.getAllByName(domain);
} catch (UnknownHostException e) {
e.printStackTrace();
}
return (myServer);
}
}

5、如何根據域名查詢ip地址

1.域名查詢IP方法,點擊開始選擇「運行」輸入cmd點擊確定,打開cmd窗口

2.輸入ping baidu.com(輸入所要查詢的域名),查詢域名ip地址

3.輸入nslookup 域名,同樣可以查詢域名ip地址。

4.查本機區域網IP方法,輸入ipconfig,查詢本機ip

6、如何通過IP查詢域名?

用ping功能就可以查到,例如要查
www.123.com
你就在運行那裡輸入
cmd
確定,在dos窗口輸入
ping
www.123.com
就可以看到動態域名的ip地址了

7、知道IP地址,如何得到對應的域名

http://whois.hichina.com/

http://www.webmasterhome.cn/whois/

開始--運行--cmd
nslookup
輸入IP地址,會反相解析出域名

8、怎樣通過ping命令獲取IP查找域名

1、WIN+R鍵打開運行,輸入cmd,進入命令提示符界面。

2、輸入命令「ping 域名」,然後回車,在輸出信息中,即可找到域名對應IP。下圖以www.baidu.com為例。

3、相較於ping命令,通過nslookup命令獲取的IP信息會更全面。同樣是通過cmd打開命令提示符界面。

4、接下來需要點擊輸入命令「nslookup 域名」,如圖所示,這樣就完成了。

9、c++域名怎麼獲取ip和埠號源程序

/////////////////////////////////////////////////////////////
//根據域名獲取IP可行,代碼如下:
//author:Wang Hongqi
//email:[email protected]
//date:2014/mar/1
///////////////////////////////////////////////////////////

#include<stdafx.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>

#include<string.h>
#include <sys/types.h>
#include <winsock2.h>

#include "iostream"
#pragma comment(lib,"ws2_32.lib")
using namespace std;

int main()
{
WSADATA wsadata;
WSAStartup(MAKEWORD(2,2),&wsadata);
hostent *phost=gethostbyname("www.hao123.com");
in_addr addr;
for(int i=0;;i++)
{
char *p=phost->h_addr_list[i];
if(p==NULL)
break;
memcpy(&addr.S_un.S_addr,p,phost->h_length);
char* ip=inet_ntoa(addr);
printf("IP地址為:%s",ip);
}

system("pause");

}

埠號怎麼取得(有不固定,即使是WEBSERVER伺服器埠號也不一定是80),呵呵!!!

與如何通過域名獲取ip相關的知識