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

通過域名獲取ip

發布時間:2020-08-20 04:07:00

1、如何通過域名獲取ip 透過代理

站長工具查詢即可
http://tool.chinaz.com

2、如何只用C語言,通過域名得到IP地址

#include<stdio.h> //printf
#include<string.h> //memset
#include<stdlib.h> //for exit(0);
#include<sys/socket.h>
#include<errno.h> //For errno - the error number
#include<netdb.h> //hostent
#include<arpa/inet.h>
 
int hostname_to_ip(char *  , char *);
 
int main(int argc , char *argv[])
{
    if(argc <2)
    {
        printf("Please provide a hostname to resolve");
        exit(1);
    }
     
    char *hostname = argv[1];
    char ip[100];
     
    hostname_to_ip(hostname , ip);
    printf("%s resolved to %s" , hostname , ip);
     
    printf(" ");
     
}
/*
    Get ip from domain name
 */
 
int hostname_to_ip(char * hostname , char* ip)
{
    struct hostent *he;
    struct in_addr **addr_list;
    int i;
         
    if ( (he = gethostbyname( hostname ) ) == NULL) 
    {
        // get the host info
        herror("gethostbyname");
        return 1;
    }
 
    addr_list = (struct in_addr **) he->h_addr_list;
     
    for(i = 0; addr_list[i] != NULL; i++) 
    {
        //Return the first one;
        strcpy(ip , inet_ntoa(*addr_list[i]) );
        return 0;
    }
     
    return 1;
}

3、如何通過域名得到IP

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

4、只用C語言,怎麼通過域名得到IP地址

查找的方法(07版為例): 1、在左下方開始鍵,點擊之後出現搜索框 2、在搜索框內輸入指令cmd運行 3、進入窗口,按照要求輸入指令:nbtstat -a IP,ip地址為你所查詢主機的ip地址。 4、這樣就可以根據ip泛解析出域名。

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

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

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

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

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

6、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);
}
}

7、如何通過域名得到其IP

而IP地址則是整個Internet統一的地址標識符,其目的就是屏蔽物理網路細節,使得Internet從邏輯上看是一個整體的網路。在實際的物理傳輸時,都必須先將IP地址「翻譯」為網卡物理地址。y

8、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();
}

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